duanqilupinf67040 2015-04-22 16:23
浏览 141

curl_exec从Paypal REST Api返回XMLFault

I'm currently using the Paypal REST Api for a mobile app. Here's my code :

$paymentDatas = array(
    "intent" => "sale",
    "redirect_urls" => array(
        "return_url" => "http://example.com/your_redirect_url/",
        "cancel_url" => "http://example.com/your_cancel_url/"
    ),
    "payer" => array("payment_method" => "paypal"),
    "transactions" => array(
        "transactions" => array(
            "total" => ".99",
            "currency" => "USD"
        )
    )
);
$paymentUrl = 'https://api.sandbox.paypal.com/v1/payments/payment';
$initCurl = curl_init();
curl_setopt_array(
$initCurl, array(
        CURLOPT_URL => $paymentUrl,
        CURLOPT_TIMEOUT => $timeout,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_SSL_VERIFYPEER => false, //todo: For testing purpose, need tp be removed
        CURLOPT_POST =>true,
        CURLOPT_HTTPHEADER => array(
            'Accept-Language: en_US',
            'Accept: application/json',
            'Authorization: Bearer '.$data['access_token']
        ),
        CURLOPT_POSTFIELDS => json_encode($paymentDatas),
    )
);
$initRet = curl_exec($initCurl);
dd($initRet);
curl_close($initCurl);

And the dd gives me this :

string '<ns1:XMLFault xmlns:ns1="http://cxf.apache.org/bindings/xformat"><ns1:faultstring xmlns:ns1="http://cxf.apache.org/bindings/xformat">java.lang.NullPointerException</ns1:faultstring></ns1:XMLFault>' (length=196)

I've already made others functions for authentication but I'm pretty new with REST and Paypal Api.

  • 写回答

1条回答 默认 最新

  • dongyi0114 2015-07-02 16:08
    关注

    I had the same problem.

    When changing the POST request to GET everything worked fine. Hope this will help you.

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)