我有一个PHP代码,可以调用facebook api me / home并获取此结果。但问题是不知道如何解码它。所以我想在这里寻求帮助。
[1]=>
object(stdClass)#276 (9) {
["id"]=>
string(31) "100000000155611_312548192088517"
["from"]=>
object(stdClass)#275 (2) {
["name"]=>
string(13) "Jun Revistual"
["id"]=>
string(15) "100000000155611"
}
["message"]=>
string(95) "lifes interesting... if you stay alive, good things are bound to happen. :))
One Piece Movie 4"
["actions"]=>
array(2) {
[0]=>
object(stdClass)#274 (2) {
["name"]=>
string(7) "Comment"
["link"]=>
string(61) "http://www.facebook.com/100000000155611/posts/312548192088517"
}
[1]=>
object(stdClass)#273 (2) {
["name"]=>
string(4) "Like"
["link"]=>
string(61) "http://www.facebook.com/100000000155611/posts/312548192088517"
}
}
["type"]=>
string(6) "status"
["created_time"]=>
string(24) "2011-11-17T05:18:17+0000"
["updated_time"]=>
string(24) "2011-11-17T05:19:31+0000"
["likes"]=>
object(stdClass)#272 (2) {
["data"]=>
array(1) {
[0]=>
object(stdClass)#271 (2) {
["name"]=>
string(16) "Andrei Natividad"
["id"]=>
string(9) "614714754"
}
}
["count"]=>
int(1)
}
["comments"]=>
object(stdClass)#269 (2) {
["data"]=>
array(2) {
[0]=>
object(stdClass)#258 (4) {
["id"]=>
string(39) "100000000155611_312548192088517_4977358"
["from"]=>
object(stdClass)#267 (2) {
["name"]=>
string(16) "Andrei Natividad"
["id"]=>
string(9) "614714754"
}
["message"]=>
string(17) "what's the title?"
["created_time"]=>
string(24) "2011-11-17T05:18:45+0000"
}
[1]=>
object(stdClass)#260 (5) {
["id"]=>
string(39) "100000000155611_312548192088517_4977363"
["from"]=>
object(stdClass)#266 (2) {
["name"]=>
string(13) "Jun Revistual"
["id"]=>
string(15) "100000000155611"
}
["message"]=>
string(37) "One Piece Movie 4: Dead End Adventure"
["created_time"]=>
string(24) "2011-11-17T05:19:31+0000"
["likes"]=>
int(1)
}
}
["count"]=>
int(2)
}
}
到目前为止我还在这里:
foreach($wall as $value) {
echo "<pre>";
echo $value[0]->id;
print_r($value);
echo "</pre>";
}
甚至不知道这是否正确。
答案 0 :(得分:0)
尝试使用此代码:
$data = $facebook_object_response;
echo $data->data[0]->id;
如果它是一个对象,您可以通过“ - &gt;”访问数据如果是数组访问它就像这个“[<index>]
”。