使用来自第三方应用的API,我使用API调用:
print_r($response->response());
结果:
(
[0] => stdClass Object
(
[id] => 41
[id_format] => 2014-{num}
[id_value] => 530
[client_id] => 37
[date_billed] => 2014-08-13 20:12:44
[date_due] => 2014-08-13 20:12:44
[date_closed] =>
[date_autodebit] =>
[status] => active
[subtotal] => 15.0000
[total] => 15.0000
[paid] => 0.0000
[previous_due] => 0.0000
[currency] => USD
[note_public] =>
[note_private] =>
[id_code] => 2014-530
[delivery_date_sent] => 2014-08-13 20:15:10
[client_id_code] => 1522
[client_first_name] => Nate
[client_last_name] => TestAccount
[client_company] =>
[client_address1] =>
[client_email] => xnumber7seven@gmail.com
[due] => 15.0000
)
)
我试图访问这些元素无济于事。 到目前为止,我已尝试过以下内容:
$test = $response->response()[0]->id;
$test = $response->response(0)->id;
$test = $response->response()->[0]->id;
$test = $response->response()->[0]id;
我似乎无法弄清楚将元素设置为变量的语法。
请不要火焰,我正在尽我所能,并会欣赏一双额外的眼睛来帮助我的愚蠢。
答案 0 :(得分:2)
尝试,
$data = $response->response();
echo $data[0]->id;