我刚刚完成了我的剧本。这是我在 PHP 中的解决方案:
$album_id = "20531316728";
$like_minimum = 5000;
$album_data = file_get_contents("https://graph.facebook.com/".$album_id."/photos");
$album_data_array = json_decode($album_data,true);
// loop album
foreach($album_data_array as $item){
// loop posts
foreach($item as $item){
// grab id, source, message
$photo_id = $item[id];
$photo_source = $item[source];
$photo_message = $item[name];
// count likes
// facebook doesn't allow us to grab this data. we'll do it anyway.
$like_data = file_get_contents("http://www.facebook.com/photo.php?fbid=".$photo_id);
$like_count = explode(' others like this.","ranges":', $like_data);
$like_count = $like_count[0];
$like_count = explode('and ', $like_count);
end($like_count);
$key = key($like_count);
$like_count = $like_count[$key];
$like_count = str_replace(",", "", $like_count);
$like_count = intval($like_count);
// check if like_minimum reached
if($like_count>$like_minimum){
// SUCCESS!
// Do stuff...
}
}
}