Skip to content

Instantly share code, notes, and snippets.

@tstachl
Created November 5, 2014 16:17
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 tstachl/715fc3ed0494101d9a81 to your computer and use it in GitHub Desktop.
Save tstachl/715fc3ed0494101d9a81 to your computer and use it in GitHub Desktop.
Assigning a user to a case written in PHP.
<?php
$json = json_encode(array(
'_links' => array(
'assigned_user' => array(
'href' => '/api/v2/users/16096734',
'class' => 'user'
)
)
));
echo($json);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://site.desk.com/api/v2/cases/3012');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_USERPWD, "agent@example.com:SuperSecretPassword");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json))
);
$result = curl_exec($ch);
curl_close($ch);
echo($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment