ban ban - 4 months ago 44
JSON Question

is it possible to have two curl_init

hi ive been trying to run this code but iam getting page isn't working not even an error can somoene point me to the right direction? thanks

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

$headers = array();
$headers[] = "Authorization: Basic plFubTHhcl93MzA4QHJJkQ9vqmNvwTpMNYYUIz5kcm9s";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
$res_decoded = json_decode($result);
echo $res_decoded->token;
$tok = $res_decoded->token;

$sh = curl_init();
curl_setopt($sh, CURLOPT_URL, "");
curl_setopt($sh, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($sh, CURLOPT_CUSTOMREQUEST, "GET");

$header = array();
$header[] = "Cwauth-Token: " . $tok;
curl_setopt($, CURLOPT_HTTPHEADER, $headers);

$results = curl_exec($sh);
if (curl_errno($sh)) {
echo 'Error:' . curl_error($sh);

echo $results;
curl_close ($ch);
curl_close ($sh);

every time the page refreshes the token changes so i need to put a dynamic token in the second header. i don't know if i'am doing the right thing here


Take a look at this:

Maybe this will help you.