PHP API Library

125 Comments

  • Brian Hartvigsen
    Comment actions Permalink

    Actually the more I think about it the more I have to wonder, are you passing the umlaut as a value or as a field name?  Can you give an example?  (Might be better to open this as an issue on http://code.google.com/p/zendesk-php-lib/issues/ )

    0
  • Brian Hartvigsen
    Comment actions Permalink

    I just tested with:

    $zd = new Zendesk("myZendeskAccount.zendesk.com", "user@name.com", "myPassword", true, true);
    $result = $zd->create(ZENDESK_REQUESTS, array(
    'details' => array(
    'description' => 'Ωå∑ƒåßπƒˆ™£®¬œ…ß˚ƒåߺ®ˆ£ä,ö,üøæå&><sadasd<![CDATA[]]>
    Sorry, don\'t have my own ZD instance to test against :(',
    'subject' => 'Testing some stuff'
    ),

    ));

     

    and it went through fine...  Make sure you have the latest version and please open a bug report if you continue to have issues (with details about the query you are trying)

    0
  • Georg M. Sorst
    Comment actions Permalink

    Hi Brian,

    thanks for the quick reply!

    I figured it out...well, partially. The included Smarty would mb_set_encoding('UTF-8') which in turn seems to mess with Zendesk lib's encoding. Why? I have no idea. Anyway, I submitted an issue: http://code.google.com/p/zendesk-php-lib/issues/detail?id=15, maybe it helps.

    0
  • Georg M. Sorst
    Comment actions Permalink

    PS: Using mb_internal_encoding('ISO-8859-1') before the request helps...

    0
  • Brian Hartvigsen
    Comment actions Permalink

    Fixed in trunk http://code.google.com/p/zendesk-php-lib/source/detail?r=33

    0
  • CAS Netlink
    Comment actions Permalink

    Hi Brian,

     

    I have a ticket that looks something like the one below. My question is - how do I get the details for just that ticket using the 'get' function? Basically, I'm trying to integrate the ability to reply to tickets in my app, so when someone clicks on the subject I need to pull the details for that ticket using the API - my first thought was that I should be able to do a search for the 'nice_id' but that always returns NULL if I try something like:

    $result = $zd->get(ZENDESK_RULES, array('nice_id' => $ticketid));

     

    stdClass Object ( [ticket_field_entries] => Array ( )

    [channel] => [nice_id] => 187 [initially_assigned_at] => [entry_id] => [created_at] => 2011/10/30 05:46:40 -0700 [has_incidents] => [resolution_time] => [priority_id] => 0 [current_tags] =>  

    0
  • Brian Hartvigsen
    Comment actions Permalink

    Getting a ticket is an interesting thing.  There are essentially 2 ways to get it, one is as an agent which includes replies and comments (which you may not want to show the end user.)  The other way is as the end-user which limits the returned data to what would be shown if they logged into your Zendesk site.  Check out http://www.zendesk.com/support/api/tickets and http://www.zendesk.com/support/api/rest-introduction for more information.

    $zd->get(ZENDESK_TICKETS, array('id' => $ticketid)); // Must be a Zendesk Agent
    $zd->get(ZENDESK_REQUESTS, array('id' => $ticketid)); // As End User, might need on-behalf-of

     

    ZENDESK_RULES is for getting a specific view of tickets, not an individual ticket.  And it should almost always be array('id' => ...).

    0
  • Georg M. Sorst
    Comment actions Permalink

    Brian, thanks for fixing the issues mb_set_encoding(), works perfectly now!

    I also just figured out a gotcha thanks to your last comment: when using the on-behalf-of option you have to use ZENDESK_REQUESTS instead of ZENDESK_TICKETS. I'm sure this has been mentioned before but it took me some time, so here it is again :)

    0
  • CAS Netlink
    Comment actions Permalink

    Thanks Brian. ZENDESKS_REQUESTS with on-behalf-of was what I needed.

    0
  • CAS Netlink
    Comment actions Permalink

    Hello Brian,

    Next question. I noticed in an earlier quote someone was saying they couldn't get comments added to existing tickets working. I'm having the same problem. I get a 403 Forbidden error. However, I can create and list tickets using the same auth details.

    Here's the var_dump of $zd after the request is sent, followed by the PHP code I'm using to add a comment to the ticket. The ticket ID and the email address for the end user are both valid.

    object(Zendesk)#2 (5) { ["account"]=> string(9) "Our Helpdesk" ["output"]=> int(0) ["secure"]=> bool(false) ["curl"]=> resource(7) of type (curl) ["result"]=> array(3) { ["header"]=> string(739) "HTTP/1.1 403 Forbidden Server: nginx/0.8.53 Date: Sun, 06 Nov 2011 15:13:51 GMT Content-Type: application/xml; charset=utf-8 Connection: keep-alive Status: 403 Forbidden P3P: CP="NOI DSP COR NID ADMa OPTa OUR NOR" X-Runtime: 50 Content-Length: 175 

    $result = $zd->update(ZENDESK_TICKETS,array(
    'id' => $post_data['ticketid'],
    'details' => array(
    'comment' => $post_data['ticket_msg']
    ),
    'on-behalf-of' => $post_data['useremail']
    ));

    0
  • CAS Netlink
    Comment actions Permalink

    I forgot to add the text version of the error that gets returned:

    'You do not have access to this page. Please contact the account owner of this help desk for further help.'

    0
  • Brian Hartvigsen
    Comment actions Permalink

    @CAS Netlink -> try:

    $result = $zd->update(ZENDESK_REQUESTS,array(
    'id' => $post_data['ticketid'],
    'details' => array(
    'value' => $post_data['ticket_msg']
    ),
    'on-behalf-of' => $post_data['useremail']
    ));

    First, updating ZENDESK_TICKET with a comment makes an administrative comment which will likely never work with on-behalf-of.

    Second, it should be "value" and not "comment".

    See http://www.zendesk.com/support/api/tickets (search for "PUT /tickets/#{id}.xml" and "PUT /requests/#{id}.xml" to see the difference between the 2 types of comments.)

    0
  • CAS Netlink
    Comment actions Permalink

    Thanks again Brian. I honestly don't know why I didn't get that. I pored through the docs and tried various arrays and values. Once I'm done with this integration I'm going to publish my PHP functions that use your library. They might save someone a bit of time. The API docs are good but I know that the transposition of the XML to PHP arrays confuses me a bit - so I'm probably not alone in that struggle :).

    Gary

    0
  • Filip Dostál
    Comment actions Permalink

    Hi,

    Thanks for this library, it is very useful. I just have one issue that I cannot figure out:

    What code will I use to update a ticket state? I am using the bellow, which does not seem to work:

    $zd->update(ZENDESK_TICKETS, array('id' => $_id, 'details' => array('created-at' => $_created, 'value' => $_comment , 'is-public' => $_is_public), 'status-id' => 2));

    Thanks!

    Filip

    0
  • Wicked Nico
    Comment actions Permalink

    Hello,

    I would like to export users but I can only get the first 100.

    Is there a trick to get the whole list ?

    Thanks,

    Nicolas

    0
  • Skip Moore
    Comment actions Permalink

    @Nicolas we not paginate the users.xml and only return 100 at a time. http://www.zendesk.com/support/api/users

    0
  • Brian Hartvigsen
    Comment actions Permalink

    @Filip 'status-id' should be part of the 'details' array.

    @Nicolas to paginate use $zd->get(ZENDESK_USERS, array(..., 'query'=>array('page'=>2))) or $zd->get(ZENDESK_USERS, array(..., 'query'=>'page=2')) .  The second way expects that you have already done the necessary formating/escaping of your query params.

    0
  • Wicked Nico
    Comment actions Permalink

    Thank you, this works now ;)

    0
  • Filip Dostál
    Comment actions Permalink

    Hey Brian,

    Thanks for you help, but I still cannot make this work. I have tried:

    $zd->update(ZENDESK_TICKETS, array('id' => $_id, 'details' => array('created-at' => $_created, 'value' => $_comment, 'is-public' => $_is_public, 'status-id' => $_status_id)));

    ...but this does not work at all, i.e. no comment is posted. Could there be something else wrong?

    Thanks,

    Filip

    0
  • Filip Dostál
    Comment actions Permalink

    In fact, even this simplified version does not work:

    $zd->update(ZENDESK_TICKETS, array('id' => $_id, 'details' => array('status-id' => 2)));

    0
  • Brian Hartvigsen
    Comment actions Permalink

    Sorry I failed to notice this on your first post, but you can not specify a comment (details->value) and update a ticket in the same call.  Comments are special and require custom XML to work.  So if you are using 'value' to post a comment, nothing else will happen (and Zendesk may well reject the request as malformed.)

    The syntax for the simplified version looks correct, if that's not working, supply a var_dump from immediately after the update is call is placed:

    $zd->update(ZENDESK_TICKETS, array('id' => $_id, 'details' => array('status-id' => 2)));
    var_dump($zd);

    and tell us if you are authenticating as a user or administrator.

    0
  • Carlos Flores
    Comment actions Permalink

    Hi Brian,

    Thank you for this.  

    Not very familiar with PHP so not sure what I'm missing but when I tried to use this (just copy pasted your code in the original post & saved the API in the same directory) I get a 500 Internal server error when I try to echo $zd and $results is empty.

    We use SSO so not sure if that makes a difference.

    Thanks for any insight you can provide.

     

     

    0
  • billy.teves
    Comment actions Permalink

    Hi Brian!,

    I am really happy that you have this Class. Zendesk has a poor documentation. . Can you please post a code for tickets that will list all the tickets with pagination? I am not sure on what parameter/s to be added on listing the tickets. 

    $result = $zd->get(ZENDESK_RULES, array( 'id' => 24616316));

    not sure if this is correct . I really need this. thanks!

    0
  • Brian Hartvigsen
    Comment actions Permalink

    @billy.teves - To paginate see the code 6 posts up from yours. That query parameter works for anything that has pagination.

    @carlos - try print_r($zd); echo is probably complaining that it can't convert an object to a string.

    0
  • billy.teves
    Comment actions Permalink

    Hi again!, 

    Why is it that when I use the above code, the return code is 302 redirect?

    https://billyhb.zendesk.com/rules/24616316

    this is the link of my ticket list

    when i use this code: $result = $zd->get(ZENDESK_RULES, array( 'id' => 24616316));

    then print_r($zd); it returns 302 redirect? I'm really not sure if I am wrong or is it really not working?

    0
  • billy.teves
    Comment actions Permalink

    I am currently using this class rev 34

    http://code.google.com/p/zendesk-php-lib/source/detail?r=34

    0
  • billy.teves
    Comment actions Permalink

    got it.! There was a problem on the class. Moving forward. Is it possible to count the ceiling of the tickets?

    I am trying to create a pagination here I want to create  <<previous | next>> OR number listing 1 2 3 4 5 6 etc.

    0
  • billy.teves
    Comment actions Permalink

    solved it sorry, yeah the sizeof array LOL. 

    0
  • billy.teves
    Comment actions Permalink

    Always redirect T_T . . please help. 

    Trying to push this data:

    $result = $zd->update(ZENDESK_REQUESTS,array(
    'id' => $p['ticketid'],
    'details' => array(
    'value' => $p['ticket_msg']
    )
    ));

    0
  • Carlos Flores
    Comment actions Permalink

    Hi again Brian,

     

    Hope you had a nice holiday.  That worked, thanks!  Is there a way to use the created on date field to limit results for users?  (i.e. return all users created after 9/20/2011)

     

    Thanks,

    C

    0

Please sign in to leave a comment.

Powered by Zendesk