CURL请求问题 [英] CURL Request problem

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

问题描述

我正在尝试验证paypal pdt信息。



我生成了我的模型表单并提交。 IT工作并返回信息。



我尝试过同样的事情做curl请求。

 <$ c> 



$ c>< form method =postaction =https://sandbox.paypal.com/cgi-bin/webscr>
< input type =hiddenname =cmdvalue =_ notify-synch/>
< input type =hiddenname =atvalue =-----/>
< input type =hiddenname =txvalue =-----/>
< input type =submitvalue =Test/>
< / form>

我的CURL REQ代码:

  $ arrData = array(
'tx'=>'----',
'cmd'=>'_notify-synch',
'at'=>'-----'
);
$ ch = curl_init('https://sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ ch,CURLOPT_POST,1);
curl_setopt($ ch,CURLOPT_POSTFIELDS,$ arrData);
$ strCurlResult = curl_exec($ ch);
curl_close($ ch);
return $ strCurlResult;

编辑:



ON tracking curl error我发现以下消息:


SSL:证书主题名称www.sandbox.paypal.com不匹配
目标主机 更改:

$ ch = curl_init('https://sandbox.paypal.com/cgi-bin/webscr');

To: $ ch = curl_init('https:// www.sandbox.paypal.com/cgi-bin/webscr');



原因:www.sandbox.paypal.com的证书对sandbox.paypal无效.com。

在表单的操作中也做同样的更改。顺便说一句。


I am trying to verify the paypal pdt information.

I generated my mockup form and submitted it. IT worked and returned the information too.

I tried the same thing making curl request. But my cur request is returning blank to me.

my mockup form:

<form method="post" action="https://sandbox.paypal.com/cgi-bin/webscr">
    <input type="hidden" name="cmd" value="_notify-synch"/>
    <input type="hidden" name="at" value="-----"/>
    <input type="hidden" name="tx" value="-----"/>
    <input type="submit" value="Test"/>
</form>

My CURL REQ Code:

$arrData = array(
    'tx'    => '----',
    'cmd'   => '_notify-synch',
    'at'    => '-----'
);
    $ch = curl_init( 'https://sandbox.paypal.com/cgi-bin/webscr' );
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ;
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $arrData);
    $strCurlResult = curl_exec($ch);
    curl_close( $ch );
    return $strCurlResult;

EDIT:

ON tracking curl error i found following message:

SSL: certificate subject name 'www.sandbox.paypal.com' does not match target host name 'sandbox.paypal.com'

解决方案

Change: $ch = curl_init( 'https://sandbox.paypal.com/cgi-bin/webscr' );
To: $ch = curl_init( 'https://www.sandbox.paypal.com/cgi-bin/webscr' );

Reason: the certificate for www.sandbox.paypal.com is not valid for sandbox.paypal.com.
Make the same change in your form's 'action' as well, by the way.

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

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