Strumenti per acquisire e convertire il Web

Gestore con PHP

PHP API

Descrizione

Problemi con il debug del gestore? Prova il Strumento di test del gestore di callback.

Il gestore qui descritto elabora i callback dal servizio web screenshot di GrabzIt. L'URL di questo gestore viene passato a GrabzIt in callBackURL parametro del Save metodo. Tuttavia questa tecnica funzionerà solo se il gestore è accessibile tramite Internet.

I seguenti parametri vengono passati al gestore come parametri GET.

Se vuoi bloccare tutti gli accessi al gestore, ad eccezione di GrabzIt, usa questo tecnica di sicurezza.

Esempio

Ricorda che questo callback non funzionerà se l'applicazione si trova su localhost.

Questo esempio mostra come è possibile implementare il gestore PHP GrabzIt. Cattura sei parametri passati dal servizio GrabzIt, incluso l'ID univoco dello screenshot che viene passato al GetResult metodo.

Questo metodo quindi restituisce lo screenshot, che è saved nella directory dei risultati. Tuttavia se a null il valore viene restituito da GetResult Questo metodo indica che si è verificato un errore.

include("GrabzItClient.php");

// This PHP file handles the GrabzIt callback

$message = $_GET["message"];
$customId = $_GET["customid"];
$id = $_GET["id"];
$filename = $_GET["filename"];
$format = $_GET["format"];
$targetError = $_GET["targeterror"];

// Custom id can be used to store user ids or whatever is needed for the later processing of the
// resulting screenshot

$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")%>");
$result = $grabzIt->GetResult($id);

if (!$result)
{
   return;
}

// Ensure that the application has the correct rights for this directory.
file_put_contents("results" . DIRECTORY_SEPARATOR . $filename, $result);