我试图让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
)
)
)
)
)
我在这里没有看到我的错误,有些帮助吗?
答案 0 :(得分:3)
只需创建一个新的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;