有人能解释我如何从中获取数据......就像我只想要主题一样,描述......等等......
stdClass Object
(
[tickets] => Array
(
[0] => stdClass Object
(
[url] => https://codemymobilecom.zendesk.com/api/v2/tickets/1.json
[id] => 1
[external_id] =>
[via] => stdClass Object
(
[channel] => sample_ticket
[source] => stdClass Object
(
[from] => stdClass Object
(
)
[to] => stdClass Object
(
)
[rel] =>
)
)
[created_at] => 2015-04-22T08:30:29Z
[updated_at] => 2015-05-19T06:01:22Z
[type] => incident
[subject] => This is a sample ticket requested and submitted by you
[raw_subject] => This is a sample ticket requested and submitted by you
[description] => This is the first comment. Feel free to delete this sample ticket.
[priority] => high
[status] => closed
[recipient] =>
[requester_id] => 794599791
[submitter_id] => 794599791
[assignee_id] => 794599791
[organization_id] => 39742491
[group_id] => 24344491
[collaborator_ids] => Array
(
)
[forum_topic_id] =>
[problem_id] =>
[has_incidents] =>
[due_at] =>
[tags] => Array
(
[0] => sample
[1] => zendesk
)
[custom_fields] => Array
(
)
[satisfaction_rating] =>
[sharing_agreement_ids] => Array
(
)
[fields] => Array
(
)
[followup_ids] => Array
(
)
[brand_id] => 565681
)
[1] => stdClass Object
(
[url] => https://codemymobilecom.zendesk.com/api/v2/tickets/10.json
[id] => 10 //multiple object like [0]...
谢谢......任何帮助都会很棒......
答案 0 :(得分:5)
当您需要访问数组的密钥时,请使用[]
。如果您有对象,请使用->
。
echo $obj->tickets[0]->subject; // returns first subject
echo $obj->tickets[0]->description; // returns first description
你可以把它放到foreach
循环中,当然是为了获得所有科目等等。
答案 1 :(得分:1)
它的STD对象所以使用属性
$obj->tickets[0]->subject
$obj->tickets[0]->description
你显然可以循环票证
foreach($obj->tickets as $ticket)
{
echo $ticket->subject;
echo $ticket->description
}
答案 2 :(得分:1)
这是一个std对象。主题和描述遵循此
$obj->tickets[0]->subject;
$obj->tickets[0]->description;
如果您在数组中感觉更好,只需使用此代码创建数组
$array = get_object_vars($obj);