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;
}