Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用基于代理的URL进行cURL_Php_Curl_Proxy - Fatal编程技术网

Php 使用基于代理的URL进行cURL

Php 使用基于代理的URL进行cURL,php,curl,proxy,Php,Curl,Proxy,我必须使用import.io api访问此网站的内容,它基于加拿大。它可以通过浏览器代理访问,但我必须使用cURL访问它,但它返回null $cc_se_page_url_autonet = "https://api.import.io/store/data/dd8eed56-4d41-4f43-aed6-ef8e7b3e9fc9/_query?input/webpage/url=http://www.autonet.ca/used-vehicles/montreal-qc/2010+2011+

我必须使用import.io api访问此网站的内容,它基于加拿大。它可以通过浏览器代理访问,但我必须使用cURL访问它,但它返回null

$cc_se_page_url_autonet = "https://api.import.io/store/data/dd8eed56-4d41-4f43-aed6-ef8e7b3e9fc9/_query?input/webpage/url=http://www.autonet.ca/used-vehicles/montreal-qc/2010+2011+2012%20-honda-accord?price=0-5000&sortby=distance+asc&kmfrom=0&kmto=13000&_user=8df097bf-2f5d-4509-b13e-299d05bad826&_apikey=8df097bf-2f5d-4509-b13e-299d05bad826%3AH76otVMlVTG2KIW9fCZjWPtf4KzWFmlNBzbD2WIy9qOKSwIPgGxmUFVmTV9dDrORwcTtMBS1zZVLXSdEd9yfPQ%3D%3D";

//  Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Set the url
#curl_setopt($ch, CURLOPT_URL, $cc_se_page_extractor_url_kijiji);
curl_setopt($ch, CURLOPT_URL, $cc_se_page_url_autonet);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);

// Will dump a beauty json :3
var_dump(json_decode($result, true));
如果在浏览器中复制/粘贴$cc_se_page_url_autonet url,您将看到joson结果,但cURL不会返回输出?使用代理访问cURL有什么解决方案吗

浏览器中的输出为:

{  
   "offset":0,
   "results":[  

   ],
   "cookies":[  
      "PHPSESSID=\"b5a335b54dd408f355726cd290c4d2ce\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_lastVisitedPage=\"%2Fused-vehicles%2Fmontreal-qc%2F2010%25202011%25202012%2520-honda-accord%3Fprice%3D0-5000\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_language=\"en\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_cityPostalCode=\"Montreal\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_userCity=\"Montreal%2C+QC\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_userCityPostalCode=\"Montreal\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "autonet_userCityRegion=\"6\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\"",
      "BIGipServeredition.autonet.ca_pool80=\"3653435146.20480.0000\";Path=\"/\";Domain=\"www.autonet.ca\";Port=\"80\""
   ],
   "connectorVersionGuid":"0603c6cf-eff5-46e2-b018-ad0bce333c5f",
   "connectorGuid":"dd8eed56-4d41-4f43-aed6-ef8e7b3e9fc9",
   "pageUrl":"http://www.autonet.ca/used-vehicles/montreal-qc/2010%202011%202012%20-honda-accord?price=0-5000",
   "outputProperties":[  
      {  
         "name":"url",
         "type":"STRING"
      }
   ]
}

您可以通过firefox firebug扩展提供浏览器请求的输出吗?我已经用浏览器中的输出更新了我的问题。这是您需要提供的: