I am having some problems forming the CURL POST to do login authentication against my helpdesk. Does anyone have example code they could post?
$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);
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_USERAGENT, $_SERVER['HTTP_USER_AGENT']); 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); curl_close($ch); highlight_string($solution);