dounuo1881 2013-12-26 15:42
浏览 58
已采纳

在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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 数据排序,可选择排序方向
  • ¥15 修改一下代码,考虑进程到达时间不同的情况
  • ¥15 华为nova10pro ,关闭热动热点用量记录
  • ¥15 树莓派ubuntu使用conda就提示core dumped
  • ¥15 帮我看看这是个啥题,带解题过程和结果,条件如下FCF = 290471.33 g1 = 15% r = 8% g2 = 4% n = 5
  • ¥15 edem模拟颗粒不显示或者生成失败
  • ¥15 Python代码编写
  • ¥15 php 将rtmp协议转hls协议,无法播放
  • ¥20 python代码编写
  • ¥20 使用MPI广播数据遇到阻塞