Skip to content

Instantly share code, notes, and snippets.

@apanzerj
Created June 11, 2012 16:10
Show Gist options
  • Save apanzerj/2910924 to your computer and use it in GitHub Desktop.
Save apanzerj/2910924 to your computer and use it in GitHub Desktop.
Former PHP GIST 1
<?php
define("ZDAPIKEY", "YOURAPIKEY");
define("ZDUSER", "YOURUSERNAME");
define("ZDURL", "https://SUBDOMAIN.zendesk.com/api/v2");
function curlWrap($url, $json)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
curl_setopt($ch, CURLOPT_URL, ZDURL.$url);
curl_setopt($ch, CURLOPT_USERPWD, ZDUSER."/token:".ZDAPIKEY);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);
curl_close($ch);
$decoded = json_decode($output);
return $decoded;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment