웹 캡처 및 변환 도구

PHP를 이용한 고급 스크린 샷 기능

PHP API

GrabzIt는 PHP API입니다 고도로 커스터마이징이 가능하며 int엄밀히 비난하다 into 신청. GrabzIt의 내부 작업을 많이 노출하므로 GrabzIt 사용 방법을 가능한 많이 사용자 지정할 수 있습니다. 이에 대한 두 가지 예는 기존 스크린 샷의 상태를 확인하고 GrabzIt이 스크린 샷을 찍거나 컨텐츠를 캡처 할 때 사용할 쿠키를 설정하는 것입니다.

스크린 샷 상태

앱에서 스크린 샷 상태를 확인하여 처리 중인지 또는 캐시되어 사용할 준비가되었는지 확인하려면 GetStatus 메서드를 사용하십시오.

$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

$status = $grabzIt.GetStatus(screenShotId);

if ($status->Processing)
{
    // screenshot has not yet been processed
}

if ($status->Cached)
{
    // screenshot is still cached by GrabzIt
}

if ($status->Expired)
{
    // screenshot is no longer on GrabzIt
    // Perhaps output status message?
    die $status->Message;
}

Cookies

대부분의 웹 사이트는 쿠키를 사용하여 기능을 제어합니다. 웹 사이트 기능의 이러한 측면을 제어 할 수있게하려면 GrabzIt을 사용하여 다음과 같이 사용자 정의 쿠키를 설정할 수 있습니다 쿠키 방법.

$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

// gets an array of cookies for google.com
$cookies = $grabzIt->GetCookies("google.com");

// sets a cookie for the google.com domain
$grabzIt->SetCookie("MyCookie", "google.com", "Any Value You Like");

// deletes the previously set cookie
$grabzIt->DeleteCookie("MyCookie", "google.com");

다운로드하지 않고 캡처 표시

캡처를 표시하기 전에 웹 서버에 캡처를 다운로드하는 것이 좋습니다. 웹 서버로 다운로드하지 않고 사용자 브라우저에서 모든 유형의 캡처를 표시 할 수도 있습니다. 그러나이 기술이 작동하려면 캡처가 완료 될 때까지 기다려야합니다.

완료되면에 의해 반환 된 캡처의 바이트를 보낼 수 있습니다 SaveTo 방법 응답과 함께 올바른 마임 유형.

$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

$grabzIt->URLToImage("https://www.tesla.com");

header("Content-Type: image/jpeg");
echo $grabzIt->SaveTo();

위의 예에서 볼 수 있듯이 파일 이름이 전달되지 않습니다. SaveTo 메소드가 캡처의 컨텐츠를 리턴하게하는 메소드.