dongyao2022 2017-02-28 13:54
浏览 535
已采纳

cUrl无法访问文件但浏览器无法访问

I want to get file contents (without file_get_contents function) via cUrl but I can't open it with cUrl

My link is here

I tested my hosting with requestb.in and results are here

$header = array();
$header[] = 'Accept-Encoding: gzip';
$header[] = 'Connection: close';
$header[] = 'Host: panel.1n3k.com';
$header[] = 'User-Agent: runscope-radar/2.0';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
curl_close($ch);

I tried with agent CURLOPT_USERAGENT with my browser's agent.

CURLOPT_REFERER, CURLOPT_ENCODING, CURLOPT_AUTOREFERER

one by one but no one could help me...

How this can be posible ?

  • 写回答

1条回答

  • drnrxv9383 2017-02-28 14:26
    关注

    try this one to view your link image contents

    <?php 
    header("Content-Type: image/jpeg");
    
    $url = 'http://panel.1n3k.com/6512bd43d9caa6e02c990b0a82652dca/api/media/4/logo/831710_1464331440.png';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.1 Safari/537.11');
    $res = curl_exec($ch);
    $rescode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
    curl_close($ch) ;
    echo $res;
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!