捕獲和轉換Web的工具

PHP的高級屏幕截圖功能

PHP API

GrabzIt的PHP API 高度可定制,並能夠 int緊要 into您的應用程序。 它揭示了GrabzIt的許多內部工作原理,因此您可以盡可能自定義如何使用GrabzIt。 這方面的兩個示例是檢查現有屏幕截圖的狀態並設置GrabzIt在獲取屏幕截圖或捕獲內容時將使用的cookie。

屏幕截圖狀態

使用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

大多數網站使用Cookie來控制功能。 為了使您能夠控製網站功能的這一方面,GrabzIt允許您使用以下內容設置自己的自定義Cookie cookie方法.

$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");

顯示捕獲而不下載

雖然我們建議您在顯示捕獲之前將其下載到Web服務器。 您也可以在用戶的瀏覽器中顯示任何類型的捕獲,而無需將其下載到Web服務器上。 但是,要使此技術起作用,用戶將不得不等待捕獲完成。

完成後,您可以發送由 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 使該方法返回捕獲內容的方法。