Skip to content

Instantly share code, notes, and snippets.

@cjroebuck
Created December 7, 2012 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjroebuck/4237105 to your computer and use it in GitHub Desktop.
Save cjroebuck/4237105 to your computer and use it in GitHub Desktop.
webshotr-v1.php
<?php
function webshotr_v1($url, $args)
{
$WEBSHOTR_APIKEY = "ca482d7e-9417-4569-90fe-80f7c5e1c781";
$WEBSHOTR_SECRET = "d18ff559-8fc2-447f-8e8d-1b1157f9b1c2";
$options['url'] = urlencode($url);
$options += $args;
foreach ($options as $key => $value) {
$_parts[] = "$key=$value";
}
$query_string = implode("&", $_parts);
$TOKEN = hash_hmac("sha1", $query_string, $WEBSHOTR_SECRET);
return "http://api.webshotr.com/v1/$WEBSHOTR_APIKEY/$TOKEN/png/?$query_string";
}
$options['width'] = "1024";
$options['height'] = "768";
$options['full_page'] = 'true';
$options['force'] = 'true';
$apicallUrl = webshotr_v1("google.com", $options);
echo $apicallUrl;
function getResource($url)
{
// initialize a handle
$chandle = curl_init();
// set URL
curl_setopt($chandle, CURLOPT_URL, $url);
// return results a s string
curl_setopt($chandle, CURLOPT_RETURNTRANSFER, 1);
// execute the call
$result = curl_exec($chandle);
curl_close($chandle);
return $result;
}
$content = getResource($apicallUrl);
echo $content;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment