1. Kayako Download customers: we will continue to develop and support Kayako Download beyond July 2017, alongside the new Kayako for existing customers.

    Find out more.

  2. The forum you are viewing relates to Kayako Classic. If you signed up or upgraded to the new Kayako (after the 4th July 2016), the information in this thread may not apply to you. You can visit the forums for the new Kayako here.

Staff API PHP example

Discussion in 'Developing, APIs and extending' started by Bryan Gintz, Mar 15, 2012.

  1. Bryan Gintz

    Bryan Gintz New Member

    I am having some problems forming the CURL POST to do login authentication against my helpdesk. Does anyone have example code they could post?
  2. Ritu

    Ritu New Member

    $data = array('username' => $_POST['username'], 'password' => $_POST['password']);
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, 'http://youracccount.kayako.com/staffapi/index.php?/Core/Default/Login');
    curl_setopt ($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt ($ch, CURLOPT_POST, 1);
    curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=".$_POST[username]."&password=".$_POST[password]);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
  3. Gurpreet Singh

    Gurpreet Singh Staff Member

    You can check this as well :

    $datatolog["username"] = utf8_encode("username");
    $datatolog["password"] = utf8_encode("password");
    $url = "http://helpdesk.com/staffapi/index.php?/staffapi/index.php?/Core/Default/Login ";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($datatolog,'','&'));
    curl_setopt($ch,CURLOPT_ENCODING , "gzip");
    $solution = curl_exec($ch);

Share This Page