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;
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.