Beste Allen,
Ik probeer data van tickets uit zendesk te halen. Dit is gelukt echter krijg ik af en toe en Warning wanneer hij data probeert op te halen waardoor hij het soms wel doet en soms niet.
Dit is mijn code:
(index document: <?php ticketsTellen($wizportaaltickets);?> )
(api document)
<?php
/*header('Content-Type: application/json');*/
ini_set('display_errors', 'On');
define("ZDAPIKEY", "XXXXXXXXXXXXXXXX");
define("ZDUSER", "[email protected]");
define("ZDURL", "https://xxxxxxx.zendesk.com/api/v2");
/* Note: do not put a trailing slash at the end of v2 */
function curlWrap($url, $json, $action)
{
$ZDAPIKEY = "";
$ZDUSER = "";
$ZDURL = "";
$ch = curl_init();
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_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
switch($action){
case "POST":
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
break;
case "GET":
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
/*echo "</br></br>get"; */
break;
case "PUT":
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
break;
case "DELETE":
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
break;
default:
break;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);
curl_close($ch);
$decoded = json_decode($output,true);
return $decoded;
}
/*ICT NIM tickets*/
$nimtickets = curlWrap('/views/62811451/execute', null, "GET");
function ticketsTellen($dataView)
{
$totalCount = 0;
$statusNieuw = 0;
$statusOpen = 0;
$statusinAfwachting = 0;
$statusGeparkeerd = 0;
$count = 0;
/*totaal tickets*/
foreach ($dataView['rows'] as $ticket )
{
if ($ticket > null)
{
$totalCount = $totalCount + 1;
}
$status = $ticket['ticket']['status'];
switch ($status)
{
case "new":
$statusNieuw++;
break;
case "open":
$statusOpen++;
break;
case "pending":
$statusinAfwachting++;
break;
case "hold":
$statusGeparkeerd++;
break;
default:
echo "Check count method ticketstellen";
}
}
echo "<p>Totaal: ".$totalCount."</br>";
echo "Nieuw: ".$statusNieuw."</br>";
echo "Open: ".$statusOpen."</br>";
echo "In afwachting: ".$statusinAfwachting."</br>";
echo "Geparkeerd: ".$statusGeparkeerd."</br>";
echo "</br></p>";
}
1.932 views