当我进行 API 调用时,我得到一个带有嵌套对象数组的对象。在 SDK 中,我将标头设置为接受:application/json。我想知道为什么我要找回对象和数组?
以下是部分回复:
PayPal\Api\CreditCard Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[type] => amex
[number] => xxxxxxxxxxx0005
[expire_month] => 5
[expire_year] => 2015
[cvv2] => 1234
[first_name] =>
[last_name] =>
[payer_id] => 3zIVtTFQ7UdKjP5mssjtzoUo6NvrsExl466oPC4Mm8nwOjI6BS
[id] => CARD-35X96613EN689504VKKCA4RA
[state] => ok
[valid_until] => 2015-06-01T00:00:00Z
[create_time] => 2013-11-13T23:41:56Z
[update_time] => 2013-11-13T23:41:56Z
[links] => Array
(
[0] => PayPal\Api\Links Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[href] => https://api.sandbox.paypal.com/v1/vault/credit-card/CARD-35X96613EN689504VKKCA4RA
[rel] => self
[method] => GET
)
)
[1] => PayPal\Api\Links Object
...等等创建这个的代码
public static function get($creditCardId, $apiContext = null) {
if (($creditCardId == null) || (strlen($creditCardId) <= 0)) {
throw new \InvalidArgumentException("creditCardId cannot be null or empty");
}
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
print_r($call);
die;
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/$creditCardId", "GET", $payLoad);
$ret = new CreditCard();
$ret->fromJson($json);
return $ret;
}