【问题标题】:PayPal API: Invalid request parameterPayPal API:请求参数无效
【发布时间】:2015-08-08 21:02:42
【问题描述】:

我正在尝试获取 PayPal 用户的基本个人数据。
当我传递属性时,它给了我这个错误:

Invalid request parameter: Requested Attributes are incorrect

API 文档:
https://developer.paypal.com/docs/classic/api/permissions/GetBasicPersonalData_API_Operation/

我的代码:

function GetBasicPersonalData(){

    $paypal_config = Config::get('paypal');

    $requestEnvelope = new RequestEnvelope();
    $requestEnvelope->errorLanguage = "en_US";

    $request = new GetBasicPersonalDataRequest();
    $request->requestEnvelope = $requestEnvelope;

    $request->attributeList = array('http://axschema.org/namePerson/first', 'http://axschema.org/namePerson/last', 'http://axschema.org/contact/email');

    $service = new PermissionsService($paypal_config);
    $response = $service->GetBasicPersonalData($request);

    return $response;
}

这是请求的样子:

PayPal\Types\Perm\GetBasicPersonalDataRequest Object
(
    [requestEnvelope] => PayPal\Types\Common\RequestEnvelope Object
        (
            [detailLevel] => 
            [errorLanguage] => en_US
        )

    [attributeList] => Array
        (
            [0] => http://axschema.org/namePerson/first
            [1] => http://axschema.org/namePerson/last
            [2] => http://axschema.org/contact/email
        )

)

然后回应:

PayPal\Types\Perm\GetBasicPersonalDataResponse Object
(
    [responseEnvelope] => PayPal\Types\Common\ResponseEnvelope Object
        (
            [timestamp] => 2015-05-26T17:27:05.060-07:00
            [ack] => Failure
            [correlationId] => 02023e9639483
            [build] => 2210301
        )

    [response] => PayPal\Types\Perm\PersonalDataList Object
        (
            [personalData] => 
        )

    [error] => Array
        (
            [0] => PayPal\Types\Common\ErrorData Object
                (
                    [errorId] => 580022
                    [domain] => PLATFORM
                    [subdomain] => Application
                    [severity] => Error
                    [category] => Application
                    [message] => Invalid request parameter: Requested Attributes are incorrect
                    [exceptionId] => 
                    [parameter] => Array
                        (
                            [0] => PayPal\Types\Common\ErrorParameter Object
                                (
                                    [name] => 
                                    [value] => PersonalAttributeList
                                )

                        )

                )

        )

)

我没有在这里看到我的错误,有帮助吗?

【问题讨论】:

  • 我会尝试将 First、Last 和 Email 的实际值放入 attributeList 数组,而不是链接到这些值。

标签: php paypal paypal-ipn


【解决方案1】:

只需创建一个新的 PersonalAttributeList 对象来保存数组属性:

$personal_attribute = new PersonalAttributeList();
$personal_attribute->attribute = array('http://axschema.org/namePerson/first', 'http://axschema.org/namePerson/last', 'http://axschema.org/contact/email');
$request->attributeList = $persoanl_attribute;

【讨论】:

    【解决方案2】:

    这对我来说是这样的:

    {
        "requestEnvelope": {
            "errorLanguage": "en_US"
        },
        "attributeList": {
            "attribute": [
                "http://axschema.org/contact/postalCode/home"
            ]
        }
    }
    

    【讨论】:

    • 欢迎来到 SO!尝试为您的答案提供更多解释。请参阅How to answer page 以帮助您改进答案。
    猜你喜欢
    • 2013-07-25
    • 2014-09-27
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多