CURL 命令行到 PHP (paypal)
CURL command line to PHP (paypal)
对不起我的英语。
我脑子里有很多困惑。
我无法在 php 中测试此行。
developer.paypal.com/webapps/developer/docs/classic/lifecycle/sb_calls/
curl -s --insecure https//api-3t.sandbox.paypal.com/nvp -d
"USER={YourUserID}
&PWD={YourPassword}
&SIGNATURE={YourSignature}
&METHOD=SetExpressCheckout
&VERSION=98
&PAYMENTREQUEST_0_AMT=10
&PAYMENTREQUEST_0_CURRENCYCODE=USD
&PAYMENTREQUEST_0_PAYMENTACTION=SALE
&cancelUrl=http//www.example.com/cancel.html
&returnUrl=http//www.example.com/success.html"
我正在使用:libcurl。
但我无法进行转换
谢谢
请注意 (a) 您在 (3) URL 中遗漏了几个“:”字符,(b) 您需要 URL 对参数键和值进行编码,并且(c) 您不需要针对指定的 Paypal 服务器避免 SSL 证书验证。但是您可以将其用于 PHP:
中的类似功能
$url = 'https://api-3t.sandbox.paypal.com/nvp';
$data = array(
'USER' => '{YourUserID}',
'PWD' => '{YourPassword}',
'SIGNATURE' => '{YourSignature}',
'METHOD' => 'SetExpressCheckout',
'VERSION' => '98',
'PAYMENTREQUEST_0_AMT' => 10,
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE',
'cancelUrl' => 'http://www.example.com/cancel.html',
'returnUrl' => 'http://www.example.com/success.html'
);
$post = http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
对不起我的英语。 我脑子里有很多困惑。
我无法在 php 中测试此行。
developer.paypal.com/webapps/developer/docs/classic/lifecycle/sb_calls/
curl -s --insecure https//api-3t.sandbox.paypal.com/nvp -d
"USER={YourUserID}
&PWD={YourPassword}
&SIGNATURE={YourSignature}
&METHOD=SetExpressCheckout
&VERSION=98
&PAYMENTREQUEST_0_AMT=10
&PAYMENTREQUEST_0_CURRENCYCODE=USD
&PAYMENTREQUEST_0_PAYMENTACTION=SALE
&cancelUrl=http//www.example.com/cancel.html
&returnUrl=http//www.example.com/success.html"
我正在使用:libcurl。 但我无法进行转换
谢谢
请注意 (a) 您在 (3) URL 中遗漏了几个“:”字符,(b) 您需要 URL 对参数键和值进行编码,并且(c) 您不需要针对指定的 Paypal 服务器避免 SSL 证书验证。但是您可以将其用于 PHP:
中的类似功能$url = 'https://api-3t.sandbox.paypal.com/nvp';
$data = array(
'USER' => '{YourUserID}',
'PWD' => '{YourPassword}',
'SIGNATURE' => '{YourSignature}',
'METHOD' => 'SetExpressCheckout',
'VERSION' => '98',
'PAYMENTREQUEST_0_AMT' => 10,
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE',
'cancelUrl' => 'http://www.example.com/cancel.html',
'returnUrl' => 'http://www.example.com/success.html'
);
$post = http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
echo $response;