dounuo1881
2013-12-26 15:42
浏览 56

在php脚本中执行curl命令并从服务器获取响应并将其解压缩

I want to verify the proof of android paypal payment to do that, I want to execute this code :

    curl https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails \
 -H "X-PAYPAL-SECURITY-USERID: user_id" \
 -H "X-PAYPAL-SECURITY-PASSWORD: password" \
 -H "X-PAYPAL-SECURITY-SIGNATURE: signature" \
 -H "X-PAYPAL-REQUEST-DATA-FORMAT: NV" \
 -H "X-PAYPAL-RESPONSE-DATA-FORMAT: NV" \
 -H "X-PAYPAL-APPLICATION-ID: APP-91B933855X481767M" \
 -d "payKey=AP-70M68096ML426802W&requestEnvelope.errorLanguage=en_US"

since I am just a beginner in php, how can I run this command in php script and receive a response

can you link me to some examples also

thank you

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douzi7890 2013-12-26 16:29
    已采纳
    $http_header = array(
        "X-PAYPAL-SECURITY-USERID: user_id",
        "X-PAYPAL-SECURITY-PASSWORD: password",
        "X-PAYPAL-SECURITY-SIGNATURE: signature",
        "X-PAYPAL-REQUEST-DATA-FORMAT: NV",
        "X-PAYPAL-RESPONSE-DATA-FORMAT: NV",
        "X-PAYPAL-APPLICATION-ID: APP-91B933855X481767M"
    );
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://svcs.sandbox.paypal.com/AdaptivePayments/PaymentDetails");
    curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header );
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "payKey=AP-70M68096ML426802W&requestEnvelope.errorLanguage=en_US");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
    
    $html = curl_exec ($ch);
    echo $html;
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题