我做了一个项目,在这部分项目中,我想保存从 graph.facebook.com 获取的数据,现在我是我从 facebook graph api 获得的项目的示例输出。:
Facebook\GraphObject Object
(
[backingData:protected] => Array
(
[data] => Array
(
[0] => stdClass Object
(
[message] => Automated XML Site Map Generator
http://pastebin.com/xjJe38dp
[id] => 103114753133019_371405176303974
[updated_time] => 2013-04-26T05:36:35+0000
)
[1] => stdClass Object
(
[message] => Simple but powerful DB class
http://pastebin.com/1qgxUrwX
[id] => 103114753133019_371404696304022
[updated_time] => 2013-04-26T05:34:23+0000
)
[2] => stdClass Object
(
[message] => Convert Existing DB to Unicode
http://pastebin.com/pHu08cPs
[id] => 103114753133019_371404609637364
[updated_time] => 2013-04-26T05:33:50+0000
)
)
[paging] => stdClass Object
(
[previous] => https://graph.facebook.com/v2.2/103114753133019/feed?fields=message&since=1366954595&access_token=425591634259397|AQumfoxQyU3wAyt3sM37sYM9sp8&limit=25&__paging_token=enc_AexpCrJr7NTOG02uEaXs6pqjd11UjEohZJLjXZrWeYLOsE9hPX7WQTLemXIGMpzdFXEDdDUQj3qdwOqEbmlAfX4TREbZ-3GAfkKiUZ44kHGYLw&__previous=1
[next] => https://graph.facebook.com/v2.2/103114753133019/feed?fields=message&access_token=425591634259397|AQumfoxQyU3wAyt3sM37sYM9sp8&limit=25&until=1366954430&__paging_token=enc_AeyPm9mOsK3T9J0JNkIyQQqxfS7hLDe5GCs-IRLQWPOOzma8v9Rzvw8awxxE0GMQhx-rfs99X7TpUGw5f7HNgPnTKh11WbGC5Yj7GyW7s2VqoA
)
)
)
如您所见,我通过运行打印这些代码:
$request = new FacebookRequest( $session, 'GET', '/a page id/feed'.$sfield );
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
// print data
echo '<pre>' . print_r( $graphObject, 1 ) . '</pre>';
所以现在我想将消息保存到文件或数据库中,当我想使用$graphObject作为数组时,它给了我一个错误:
Fatal error: Cannot use object of type Facebook\GraphObject as array in /home/micengco/public_html/parser/facebook.php on line 34
那我怎么能做到这一点?