Getting Zero (0) When calling an enpoint through curl
$ch = curl_init();
$data = array("query" => "type:ticket status:open");
$payload = json_encode($data);
$headers = array(
'Content-Type:application/json',
'Authorization: Basic '. base64_encode("your-email@gmail.com/token:your-token")
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL,"https://your-site.zendesk.com/api/v2/search.json");
//curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
// curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
// Receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//$server_output = curl_exec($ch);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ( $httpCode != 200 ){
echo "Return code is {$httpCode} \n"
.curl_error($ch);
} else {
echo "<pre>".htmlspecialchars($response)."</pre>";
}
curl_close($ch);
Iniciar sesión para dejar un comentario.
0 Comentarios