Php Paypal PDT无法使用CURL
Paypal返回站点并给出了交易ID,现在使用CURL发布数据,但它不起作用,有人能帮我吗。它没有打印成功消息。我已经搜索了堆栈溢出,但仍然没有结果Php Paypal PDT无法使用CURL,php,curl,paypal,Php,Curl,Paypal,Paypal返回站点并给出了交易ID,现在使用CURL发布数据,但它不起作用,有人能帮我吗。它没有打印成功消息。我已经搜索了堆栈溢出,但仍然没有结果 $tx = $_GET['tx']; $ID = $_GET['cm']; $currency = $_GET['cc']; $identity = '0iMIW7w4OXAed9Tvz6l9fpUY8B-E_WtE3toU7sT5gIzDJc9uPUgt9sVCN30
$tx = $_GET['tx'];
$ID = $_GET['cm'];
$currency = $_GET['cc'];
$identity = '0iMIW7w4OXAed9Tvz6l9fpUY8B-E_WtE3toU7sT5gIzDJc9uPUgt9sVCN30';
// Further processing
// Init cURL
// Init cURL
$request = curl_init();
// Set request options
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$fields = array(
'cmd' => '_notify-synch',
'tx' => $tx,
'at' => $identity,
);
curl_setopt($request,CURLOPT_URL, $url);
curl_setopt($request,CURLOPT_POST, count($fields));
curl_setopt($request,CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($request,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request,CURLOPT_HEADER, FALSE);
// Execute request and get response and status code
$response = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_HTTP_CODE);
// Close connection
curl_close($request);
我看不到任何“成功消息”,也看不到任何在curl请求后输出任何内容的尝试,唯一让我震惊的是——其他人可能不同意——在选项中没有任何内容专门处理https通信,根据我的经验,这需要设置其他选项。我以前没有处理过PayPal api,所以这可能没有什么用处,但是
试着下载一份cacert.pem
——谷歌是你的朋友
<?php
$tx = $_GET['tx'];
$ID = $_GET['cm'];
$currency = $_GET['cc'];
$identity = '0iMIW7w4OXAed9Tvz6l9fpUY8B-E_WtE3toU7sT5gIzDJc9uPUgt9sVCN30';
/* Use the full path to your own cacert.pem, download from the interwebs if you do not have a copy */
$cacert = 'c:/wwwroot/cacert.pem';
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$fields = array(
'cmd' => '_notify-synch',
'tx' => $tx,
'at' => $identity,
);
$request = curl_init();
curl_setopt($request,CURLOPT_URL, $url);
if( parse_url( $url,PHP_URL_SCHEME )=='https' ){
curl_setopt( $request, CURLOPT_SSL_VERIFYPEER, FALSE ); /* set to true once you get this working */
curl_setopt( $request, CURLOPT_SSL_VERIFYHOST, 2 );
curl_setopt( $request, CURLOPT_CAINFO, realpath( $cacert ) );
}
/* this should be true or false not count($fields): in this case true*/
/*curl_setopt($request,CURLOPT_POST, count( $fields ) );*/
curl_setopt($request,CURLOPT_POST, true );
curl_setopt($request,CURLOPT_POSTFIELDS, http_build_query( $fields ) );
curl_setopt($request,CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request,CURLOPT_HEADER, FALSE);
/* Quite often requests get rejected for no useragent */
curl_setopt($request,CURLOPT_USERAGENT, 'paypal-mozilla-chrome-useragent' );
curl_setopt($request, CURLINFO_HEADER_OUT, TRUE );
$response = curl_exec($request);
$status = curl_getinfo($request, CURLINFO_HTTP_CODE);
curl_close($request);
/* See what the curl request has retrieved */
echo '<pre>',print_r( $response, true ),$status,'</pre>';
?>
如何检查curl是否正在发布数据?是Fred Gwyn吗?;-)+谢谢你的帮助。虽然我唯一做的php就是阅读这里的问题,但我认为您已经了解了关于https
args的内容。同样对于o.p.,S.o.也是你的朋友。尝试搜索[paypal][php]
,我看到了~3550个Q/As。祝大家好运。当我放大时,我想,那不可能是他,他看起来太年轻了!;-)