我从服务源中提取了以下 JSON 内容:
[
{
"global_event":{
"ending_at":"2011-11-07T02:00:00Z",
"short_url":"http://bit.ly/reAhRw",
"created_at":"2011-10-04T14:25:41Z",
"event_responses":[
],
"addresses":{
"location":{
"city":"blah",
"latitude":30.205288,
"zipcode":"343434",
"street":"blah",
"longitude":-95.475289,
"state":"TX"
}
},
"body":"blahblahblah",
"euid":"2f489d0c82d167f1c16aba5d3b4c29ade6f1d52a",
"title":"Fusion",
"updated_at":"2011-10-04T14:26:57Z",
"event_roles":[
],
"user":{
"long_name":"Fusion Single",
"nickname":""
},
"event_items":[
],
"starting_at":"2011-11-07T00:00:00Z"
}
}
]
我尝试了以下代码来解析它,但没有成功:
$json = @file_get_contents('jsonfeed');
$feed = json_decode($json);
foreach($feed->global_event as $item) {
$rss_item = array(
'title' => $item->title,
'link' => $item->short_url,
'author' => $item->long_name,
'content' => $item->body,
'date' => $item->updated_at,
'type' => 'Woodlands Church'
);
array_push($this->rss, $rss_item);
}
最终创建的数组$this->rss
其中从来没有任何内容,只是一个空数组。有任何想法吗?