对cURL请求PHP的空响应 [英] Blank Reponse on a cURL Request PHP

查看:139
本文介绍了对cURL请求PHP的空响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cURL提出了一个API请求,但我得到一个空白的结果。我试图 var_dump 的url然后尝试在浏览器的url和工作正常。这是我的代码。

I am making an API request using cURL but I'm getting a blank result. I tried to var_dump the url then tried the url on the browser and works fine. Here's my code.

$parameters = array(
            "user" => urlencode('xxxx'),
            "password" => urlencode('xxxx'),
            "msisdn" => urlencode('09277878067'),
            "type" => urlencode('full'),
        );

        $post_data = '';
        //create name value pairs seperated by &
        foreach($parameters as $k => $v) 
        { 
            $post_data .= $k . '='.$v.'&'; 
        }

        // Remove the & from the last
        $post_data2 = rtrim($post_data, '&');
        $url = "http://www.telcoportal.com/hlr/check?";

        $ch = curl_init();  
        curl_setopt($ch,CURLOPT_URL,$url.$post_data2);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
        curl_setopt($ch,CURLOPT_HEADER, false); 
        curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, false); 
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);   
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); 
        $output=curl_exec($ch);

        curl_close($ch);

        var_dump($output);
        var_dump($url.$post_data2);
        exit();

$ url。$ post_data2 code> http://www.telcoportal.com/hlr/check?user=xxxx&password=xxxx&msisdn=09277878032&type=full 其中,当您检查浏览器时给出响应 {status:error,remark:Authentication Failed} 。但我的 $ output 是空白的,没有得到任何东西。谢谢。

The $url.$post_data2 is http://www.telcoportal.com/hlr/check?user=xxxx&password=xxxx&msisdn=09277878032&type=full which when you checked the browser gives a response {"status":"error","remark":"Authentication Failed"} . But my $output is blank and not getting anything. Thanks.

推荐答案

找到了。这是他们使用 https 。它现在工作。对不起,noob问题。感谢

Found it. It's the they use https . it's working now. Sorry for the noob question. thanks

这篇关于对cURL请求PHP的空响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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