Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.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空白空间_Php_Curl - Fatal编程技术网

卷曲php空白空间

卷曲php空白空间,php,curl,Php,Curl,当我在浏览器中键入URL时,它会返回详细的输出。然而,当我试图通过curl请求来实现这一点时,该请求返回一个空白。为什么会这样 URL是 我的代码是: <!DOCTYPE html> <?php function fetchData($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT

当我在浏览器中键入URL时,它会返回详细的输出。然而,当我试图通过curl请求来实现这一点时,该请求返回一个空白。为什么会这样

URL是

我的代码是:

<!DOCTYPE html>


<?php



function fetchData($url) {
             $ch = curl_init();
               curl_setopt($ch, CURLOPT_HEADER, 1);
   curl_setopt($ch, CURLOPT_VERBOSE, 1);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
   curl_setopt($ch, CURLOPT_FAILONERROR, 0);
   curl_setopt($ch, CURLOPT_URL, $url);
   $returned = curl_exec($ch);
   echo 'Errors: ' . curl_errno($ch) . ' ' . curl_error($ch) . '<br><br>';
   curl_close ($ch);
   echo $returned;
             return $returned;
    }


);
        // Pulls and parses data.

    $returned = fetchData("https://api.500px.com/v1/users?oauth_token=xElRwQ6cqItG8Siy9kFBpwkj5sCdlp33NRva5TZU&oauth_verifier=hbNdYnqm8BSyuiZYa4KZ&consumer_key=0OvWThqr5j1ZYX1cPaa8y0y1aOfJBbDtpX85fJ42");
    var_dump($returned);
if(curl_exec($ch) === false)
{
    echo 'Curl error: ' . curl_error($ch);
}


请使用CURLOPT_标题检查响应标题是否有任何错误。

使用以下格式的curl-

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,'client='.$number.'&order='.$orderId);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
$data =curl_exec($ch);

我下面的url给了我一个空白page@StephenTG抱歉,访问代码只有一次有效,这意味着其他人单击了链接。我现在就给你发一封。听起来这可能是问题所在…@StephenTG试试这个:@StephenTG有没有办法让我把你分开?所以设置这个curl\u setopt($curl,CURLOPT\u HEADER,true)?我发现:HTTP错误411所需长度curlopt_useragent有什么意义?当通过cURL请求URL时,服务器会像通过浏览器发送请求一样响应请求。但是,默认的cURL请求没有指定某些服务器验证请求所需的信息,例如用户代理、语言等。此代码不起作用。我为我的exmaple修改了它,它在500px页面返回,上面说oops肯定有错误。