图api不会返回好的数据,为什么?

时间:2013-11-25 16:01:36

标签: php facebook facebook-graph-api facebook-javascript-sdk facebook-fql

我使用图形api来捕捉相册中照片的喜欢,分享和评论。在大多数情况下它表现不错,但有一些可以获得喜欢,分享和评论专辑而不是图片。我不知道为什么。

我使用php和两个fql:

//get all photo ids of one album

$user_id= "my user id";
$photo_limit= "my limit";
$album_name="my album name";
$access_token= "my access token";

$fql_query_url = 'https://graph.facebook.com'.
'fql?q=SELECT+object_id+FROM+photo+WHERE+album_object_id+in+
(SELECT+object_id,+name+FROM+album+WHERE+owner+=+'.$user_id.'
+and+name+=+"'.$album_name.'")+limit+'.$photo_limit. '&access_token=' . $access_token;

$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);



//print the likes, shares, and comments of all photos
foreach ($fql_query_obj["data"] as $photo_id){

$id = $photo_id["object_id"];
$fql_query_url_1 = 'https://graph.facebook.com/'.
'fql?q=SELECT+like_info.like_count,+comment_info.comment_count,+share_count,+
created_time+from+stream+where+post_id+in
(Select+page_story_id+from+photo+where+object_id+=+'.$id.')'.
'&access_token='.$access_token;

$fql_query_result_1 = file_get_contents($fql_query_url_1);
$fql_query_obj_1 = json_decode($fql_query_result_1, true);

echo $fql_query_obj_1["data"][0]["like_info"]["like_count"].",".
$fql_query_obj_1["data"][0]["comment_info"]["comment_count"].",".
$fql_query_obj_1["data"][0]["share_count"]."\n";

}

在循环中的一些照片中返回错误数据。为什么???

提前致谢。

0 个答案:

没有答案