【问题标题】:CURL command line to PHP (paypal) [closed]CURL命令行到PHP(贝宝)[关闭]
【发布时间】:2015-03-14 11:18:35
【问题描述】:

对不起我的英语。 我脑子里有很多困惑。

我无法在 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。 但我无法进行转换

谢谢

【问题讨论】:

    标签: php curl paypal


    【解决方案1】:

    请注意,(a) 您在 (3) 网址中缺少几个“:”字符,(b) 您需要对参数键和值进行网址编码,以及 (c) 您不需要避免使用 SSL针对指定的 Paypal 服务器的证书验证。但是您可以将其用于 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;
    

    【讨论】:

      猜你喜欢
      • 2021-03-23
      • 2013-04-18
      • 1970-01-01
      • 2017-06-29
      • 1970-01-01
      • 1970-01-01
      • 2012-02-18
      • 1970-01-01
      • 2023-04-04
      相关资源
      最近更新 更多