Over 10 years we help companies reach their financial and branding goals. Engitech is a values-driven technology agency dedicated.

Gallery

Contacts

285A Gateshead Road, Borehamwood, Greater London, WD6 5LZ.

info@vbridge.co.uk

+44 203 488 9980

+0203 488 0088

Blog

Aim:

To get count of tickets for every day.
 

User flow and implementation:

 

Step 1: Authorization as per https://support.zendesk.com/entries/24458591-Using-OAuth-authentication-with-your-application

 

  • Redirect the user to the authorization page in ZenDesk
  • Get authorized using the access token.

 
Step 2: Get count of tickets created for a particular date.
 

curl Call:

 

  • curlWrap($zendfetchmail, $zendfetchkey, $zendfetchurl, “/api/v2/search.json?query=created>$dayin”, null, “GET”);

Note: curlWrap is a curl function which gives the response output. It passes the parameters of <mail_id>,<API key>, <app_url>,<request url>.

 

<request url> specifies our request. If we want to request for create a new ticket the url endpoint must be “/tickets.json”. Here <request url> =”/api/v2/search.json?query=created>$dayin” .Here $dayin is date passing for get the result for the particular date.Here we uses the operator “>”, it means the result returns the most recent tickets. In our code we send the <yesterday’s date> since we want to get the details daily.
 

curlWrap:

 

function curlWrap($ZDUSER, $ZDAPIKEY, $ZDURL, $url, $json, $action)

{       $ch = curl_init();

       // set url

       curl_setopt($ch, CURLOPT_URL, $ZDURL.$url);

       curl_setopt($ch, CURLOPT_USERPWD, $ZDUSER.”/token:”.$ZDAPIKEY);

       //return the transfer as a string

    .     .    .    .

       $options[CURLOPT_USERAGENT] = $useragent;

       curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

      curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);

          $output = curl_exec($ch);  //output

         curl_close($ch);

          $decoded = json_decode($output,1);

    return $decoded;

}
 

Response:

 

The response we get contains count, next_page, prev_page, results

count : The total number of results matching this query

next_page:URL to the next page of results.

prev_page: URL to the previous page of results.

results: May consist of Tickets, Users, Groups, Organizations, and Topics.

 
 

Integration and interaction diagrams

 
1. Authorize App using Zendesk.

2. Get Refresh token and Access token from Zendesk.

 
 

3.Get count of tickets for particular date.

PHP Library:

 
https://code.google.com/p/zendesk-php-lib/
 

Links: