【问题标题】:curl_exec return an XMLFault from Paypal REST Apicurl_exec 从 Paypal REST Api 返回一个 XMLFault
【发布时间】:2015-04-22 16:23:45
【问题描述】:

我目前正在将 Paypal REST Api 用于移动应用程序。 这是我的代码:

$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);

dd 给了我这个:

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)

我已经为身份验证创建了其他功能,但我对 REST 和 Paypal Api 还是很陌生。

【问题讨论】:

    标签: php rest curl paypal


    【解决方案1】:

    我遇到了同样的问题。

    将 POST 请求更改为 GET 时,一切正常。希望这会对你有所帮助。

    【讨论】:

    • 感谢您的回答 :) 我通过更改标题解决了我的问题。这个不正确(以收为例)
    猜你喜欢
    • 2020-07-30
    • 2015-04-25
    • 2013-06-26
    • 2016-03-18
    • 2015-07-18
    • 2013-03-20
    • 2013-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多