将Curl转换为php

时间:2016-11-26 09:47:03

标签: php curl

是否可以将此curl命令转换为PHP?

curl -H "cwauth-token: CwEqP_oQXCiDKt3ph0leZ2AlKsqE6E4N " "https://reports.voluum.com/report?from=2014-09-24T00%3A00%3A00Z&to=2014-0925T00%3A00%3A00Z&tz=Europe%2FWarsaw&sort=visits&direction=desc&columns=campa ignName&columns=visits&columns=clicks&columns=conversions&columns=revenue&co lumns=cost&columns=profit&columns=cpv&columns=ctr&columns=cr&columns=cv&colu mns=roi&columns=epv&columns=epc&columns=ap&columns=errors&groupBy=campaign&o ffset=0&limit=100&include=active"

1 个答案:

答案 0 :(得分:1)

这是鱼:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://reports.voluum.com/report?from=2014-09-24T00%3A00%3A00Z&to=2014-0925T00%3A00%3A00Z&tz=Europe%2FWarsaw&sort=visits&direction=desc&columns=campa ignName&columns=visits&columns=clicks&columns=conversions&columns=revenue&co lumns=cost&columns=profit&columns=cpv&columns=ctr&columns=cr&columns=cv&colu mns=roi&columns=epv&columns=epc&columns=ap&columns=errors&groupBy=campaign&o ffset=0&limit=100&include=active");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

$headers = array();
$headers[] = "Cwauth-Token: CwEqP_oQXCiDKt3ph0leZ2AlKsqE6E4N";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);

以下是如何钓鱼:
https://curl.haxx.se/docs/manpage.html
https://secure.php.net/manual/en/function.curl-setopt.php

这里有一些可以使用的钓鱼机器:
http://curl.trillworks.com/#php
https://incarnate.github.io/curl-to-php/

顺便说一句,这就是为什么你应该考虑钓鱼的替代方案: