Created
June 11, 2012 16:10
-
-
Save apanzerj/2910924 to your computer and use it in GitHub Desktop.
Former PHP GIST 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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