【问题标题】:receive curl request接收 curl 请求
【发布时间】:2012-06-16 05:34:08
【问题描述】:

我在我的程序中使用 curl。
我的代码是:

$tref = $_GET['tref'];

$url = "https://paypaad.bankpasargad.com/PaymentTrace";
$curl_session = curl_init($url); // Initiate CURL session -> notice: CURL should be enabled.
curl_setopt($curl_session, CURLOPT_POST, 1);    // Set post method on.
//curl_setopt($curl_session, CURLOPT_FOLLOWLOCATION, 1); // Follow where ever it goes
curl_setopt($curl_session, CURLOPT_HEADER, 0); //Don't return http headers
//curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); // Return the content of the call
$post_data = "tref=".$tref;
curl_setopt($curl_session, CURLOPT_POSTFIELDS, $post_data);

// Get returning data
$output = curl_exec($curl_session);
print_r($output);
print_r($post_data);

但是当我在主机中使用此代码时,$output 未设置,并且当正确使用另一台服务器时此代码。
我在服务器上的表现如何。

【问题讨论】:

    标签: php curl


    【解决方案1】:

    嘿,找到了这段代码:

    $data = curl_exec($curl_handle);
    if ($data === FALSE) {
       die(curl_error($curl_handle));
    } else {
       $html_str .= $data;
    }
    

    当我使用这段代码时,我遇到了这个错误:

    SSL 证书问题,验证 CA 证书是否正常。详细信息:错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败

    然后我搜索这个错误并面对这个链接 http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

    我添加了这段代码

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    之前

    curl_exec():

    【讨论】:

    • 您可以选择自己的答案。请这样做,让社区知道它已解决,遇到相同问题的人也能看到它已解决。
    【解决方案2】:

    确保您的服务器 curl 已启用..

    更改;extension=php_curl.dll

    extension=php_curl.dll
    

    在 php.ini 中你也检查了这个Call to undefined function curl_init().?

    【讨论】:

    • 这是一种禁用它的方法:/
    • 是的,此扩展已启用,我可以发送对 url 的请求,但我无法从 url 接收。
    猜你喜欢
    • 1970-01-01
    • 2013-03-05
    • 1970-01-01
    • 2015-10-12
    • 2014-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多