2015-01-15 178 views
-2

對不起,我的英文。 我的腦海裏有很多混亂。CURL命令行到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中。 但我不能做轉換

感謝

回答

0

需要注意的是(一)你錯過了幾個「:」字符的(3)的網址,(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;