Created
December 17, 2013 19:11
-
-
Save tstachl/8010843 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$case = array( | |
'type' => 'email', | |
'subject' => 'Email Case Subject', | |
'priority' => 4, | |
'status' => 'open', | |
'labels' => array('Spam', 'Ignore'), | |
'message' => array( | |
'direction' => 'in', | |
'body' => 'Example Body', | |
'to' => '[email protected]', | |
'from' => '[email protected]', | |
'subject' => 'My email subject' | |
), | |
'_links' => array( | |
'customer' => array( | |
'href' => '/api/v2/customer/1' | |
) | |
) | |
); | |
$case_string = json_encode($case); | |
echo $case_string; | |
echo "\n\n"; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://yoursite.desk.com/api/v2/cases"); | |
curl_setopt($ch, CURLOPT_PORT, 443); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 15); | |
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); | |
curl_setopt($ch, CURLOPT_USERPWD, "email:password"); | |
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $case_string); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($case_string) | |
) | |
); | |
$return = curl_exec($ch); | |
echo $return; | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment