你好我一直试图运行这个代码,但我得到的页面是不工作,甚至一个错误可以somoene指向我正确的方向?感谢
<?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);
?>
每次页面刷新令牌更改,所以我需要在第二个标头中放置一个动态令牌。我不知道我是否在这里做正确的事