我是PayPal API的新手,我在使用
PHP中的CURL调用SetExpressCheckout时遇到了麻烦.
就我而言,我已经正确设置了所有内容,但我一直收到81002错误“指定的方法不受支持”.
就我而言,我已经正确设置了所有内容,但我一直收到81002错误“指定的方法不受支持”.
<?PHP $paypal_data = array( 'USER' => urlencode('andree_1272823561_biz_api1.gmail.com'),'PWD' => urlencode('1272823576'),'SIGNATURE' => urlencode('Am1t0wiu2tv7VwZ5ebdeY9zv1GF6Ad0PFz-qTGFFf7vbWU6ee4bxy8KL'),'VERSION' => urlencode('52.0'),'PAYMENTACTION' => urlencode('Sale'),'METHOD' => urlencode('SetExpressCheckout'),'AMT' => urlencode('52.00'),'RETURNURL' => urlencode('get_express_checkout_details.PHP'),'CANCELURL' => urlencode('index.PHP') ); $url = 'https://api-3t.sandBox.paypal.com/nvp?' . http_build_query($paypal_data); $curl = curl_init(); curl_setopt($curl,CURLOPT_URL,$url); curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); curl_setopt($curl,CURLOPT_CAINFO,dirname(__FILE__) . '/cacert.pem'); $result = curl_exec($curl); curl_close($curl); parse_str($result,$result); ?> <pre>Data sent: <?PHP print_r($paypal_data); ?></pre> <pre>Result: <?PHP print_r($result); ?></pre>
当我运行代码时,输出如下:
Data sent: Array ( [USER] => andree_1272823561_biz_api1.gmail.com [PWD] => 1272823576 [SIGNATURE] => Am1t0wiu2tv7VwZ5ebdeY9zv1GF6Ad0PFz-qTGFFf7vbWU6ee4bxy8KL [VERSION] => 52.0 [PAYMENTACTION] => Sale [METHOD] => SetExpressCheckout [AMT] => 52.00 [RETURNURL] => get_express_checkout_details.PHP [CANCELURL] => index.PHP ) Result: Array ( [ACK] => Failure [L_ERRORCODE0] => 81002 [L_SHORTMESSAGE0] => Unspecified Method [L_LONGMESSAGE0] => Method Specified is not Supported [L_SEVERITYCODE0] => Error )
谁知道可能是什么问题?
此致,Andree.
问题是当你使用urlencode http_build_query时.您将最终使用双重编码,PayPal将拒绝某些信息.