dsqtl335227 2016-01-21 16:43
浏览 41
已采纳

主机服务器上的卷曲返回false(启用卷曲)

Using:

hostinger free
php 5.5.26
curl enabled 7.19.7
"laravel/framework": "5.2.*" and "vladkens/vk": "^0.1.9"

I'm getting false response(bool(false)) using this function:

private function request($url, $method = 'GET', $postfields = array())
{
    curl_setopt_array($this->ch, array(
        CURLOPT_USERAGENT =>"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_POST => ($method == 'POST'),
        CURLOPT_POSTFIELDS => $postfields,
        CURLOPT_URL => $url
    ));

    return curl_exec($this->ch);
}

Using curl_getinfo($this->ch) getting this debugging data:

array(23) { ["url"]=> string(251) "https://api.vk.com/method/audio.search.json?access_token={{access_token}}&api_id={{api_id}}&q=21+Hunter+Hayes&random=1014×tamp=1453393550&v=2.0&sig={{sig}}" ["content_type"]=> NULL ["http_code"]=> int(0) ["header_size"]=> int(0) ["request_size"]=> int(0) ["filetime"]=> int(0) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0) ["namelookup_time"]=> float(0) ["connect_time"]=> float(0) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(-1) ["starttransfer_time"]=> float(0) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(0) "" ["certinfo"]=> array(0) { } } 

And if I use from this array directly in browser url value I will get proper api.vk.com reponse with data.

What I'm missing?
UPDATE:
Getting this message couldn't connect to host usingecho $error = curl_error($this->ch);

  • 写回答

1条回答 默认 最新

  • duanlei5339 2016-01-21 17:26
    关注

    You seem unable to reach internet from your server. It sounds like a firewall issue. Go to your panel and ensure there are no firewall rules preventing you from acessing outside web sites. It could be a limitation due to your hosting plan.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号