curl在hostinger服务器上返回false(启用curl) [英] Curl return false on hostinger server (curl enabled)

查看:402
本文介绍了curl在hostinger服务器上返回false(启用curl)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用:


hostinger免费

php 5.5.26

curl已启用7.19.7

laravel / framework:5.2。*和vladkens / vk:^ 0.1.9

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

我使用此函数得到了错误响应( bool(false)):

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);
}

使用 curl_getinfo($ this-> ch) 获取此调试数据:

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) { } } 



如果我在浏览器中直接使用这个数组 url value我会得到适当的api.vk.com响应数据。

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

我缺少什么? b $ b 更新:

获取此消息无法使用连接到主机 $ error = curl_error($ this-> ch);

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

推荐答案

互联网从你的服务器。
这听起来像一个防火墙问题。
转到您的面板,并确保没有防火墙规则阻止您访问外部网站。这可能是由于您的托管计划的限制。

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.

这篇关于curl在hostinger服务器上返回false(启用curl)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆