11-09-2013 04:49 AM
11-13-2013 09:19 AM
11-13-2013 09:30 AM
function get_ticket_curl_post($u, $pw) {
$ticket = ''; //init
$credentials = array('username' => $u, 'password' => $pw);
$ch = curl_init(URL_SERVER.'s/api/login');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($credentials));
curl_setopt($ch, CURLOPT_TIMEOUT, 25);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/html'));
$postResult = curl_exec($ch);
// Check if any error occured
if(curl_errno($ch)) {
$ticket = ''; //no ticket.
}
else {
$ticket = json_decode($postResult)->data->ticket; //set ticket to return
}
curl_close($ch);
// die($ticket);
return $ticket;
}
/* Execution des methodes GET */
function requestGet($lien, $val, $ticket=null) {
$url = URL_SERVER.$lien;
$request = new HttpRequest($url, HTTP_METH_GET);
if ($ticket != null) {
$request->addHeaders(array('Authorization' => 'Basic '.base64_encode($ticket)));
//$request->addQueryData(array('alf_ticket' => $ticket));
}
if ($val != null) {
$request->addQueryData($val);
}
try {
$response = $request->send();
} catch (HttpException $ex) {
echo $ex;
}
return $response;
}
function requestPost($lien, $val, $ticket=null) {
$url = URL_SERVER.$lien;
$request = new HttpRequest($url, HTTP_METH_POST);
if ($ticket!=null)
$request->addHeaders(array('Authorization' => 'Basic '.base64_encode($ticket)));
if ($val!=null)
$request->addPostFields($val);
try {
$response = $request->send();
} catch (HttpException $ex) {
echo $ex;
}
return $response;
}
11-14-2013 02:35 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.