2
您好一直在試圖運行這段代碼,但我得到頁面不工作,即使一個錯誤可能somoene指向我的正確方向嗎?謝謝是否有可能有兩個curl_init
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://security.voluum.com/login");
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, "https://reports.voluum.com/report?from=2016-11-24T00%3A00%3A00Z&to=2016-11-26T00%3A00%3A00Z&tz=Europe%2FWarsaw&sort=visits&direction=desc&columns=campaignName&columns=visits&columns=clicks&columns=conversions&columns=revenue&columns=cost&columns=profit&columns=cpv&columns=ctr&columns=cr&columns=cv&columns=roi&columns=epv&columns=epc&columns=ap&columns=errors&groupBy=campaign&offset=0&limit=100&include=active");
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);
?>
每當頁面刷新令牌更改,所以我需要在第二個標頭中放入一個動態令牌。我不知道如果我'在這裏做了正確的事情
謝謝你的迴應,我解決了這個問題,我自己得到了一個錯誤的變量名,我把頭放在第二個數組而不是頭:D – ban