0

in adobe connect api there is 2 step for getting data:

step 1) from http://87.107.152.107/api/xml?action=login&login=username&password=password I have to get token to verify in other api.

step 2) from http://87.107.152.107/api/xml?action=report-my-meetings I can get meetings report with token got from step 1.

the problem is when I use postman to use these api , postman set cookie from step 1 api. and it needs this cookie for step 2.

I want to use cookie in curl php but I don't know how to get it. My code for step 1:

    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_URL => 'http://87.107.152.107/api/xml?action=login&login=username&password=password',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'GET',
    ));

    $response = curl_exec($curl);
Siavash
  • 11
  • 6

1 Answers1

0

I used this and worked for me:

    curl_setopt($ch, CURLOPT_HEADER, 1);
//Return everything
$res = curl_exec($ch);
//Split into lines
$lines = explode("\n", $res);
$headers = array();
$body = "";
foreach($lines as $num => $line){
    $l = str_replace("\r", "", $line);
    //Empty line indicates the start of the message body and end of headers
    if(trim($l) == ""){
        $headers = array_slice($lines, 0, $num);
        $body = $lines[$num + 1];
        //Pull only cookies out of the headers
        $cookies = preg_grep('/^Set-Cookie:/', $headers);
        break;
    }
}
Siavash
  • 11
  • 6