I am working on a facebook app and since its my first facebook app, I am facing some problems with the PHP API.
I want to fetch the name and profile ID of the sender who sent maximum no. of messages. I am new to PHP and facing problems in proceeding after getting inbox object. Any help would be appreciated.
I am stuck here
$inbox = $user_profile['inbox'];
user_profile
is an array where the data of user's profile and account is stored.
Use the PHP API to make a FQL request to the thread table. This will give you the Facebook ID of the originator :
$params = array(
'method' => 'fql.query',
'query' => "SELECT originator, message_count FROM thread WHERE viewer_id = 8675309 and folder_id = 0 ORDER BY message_count DESC LIMIT 0,10");
$threads = $facebook->api($params);
Set the viewer_id appropriately. Notice the ORDER BY and LIMIT. This FQL is giving you the TOP 10 senders based on message_count. Then, if you need to get their name :
foreach($threads as $thread)
{
print_r($thread);
$originator = file_get_contents("http://graph.facebook.com/$thread['originator']");
$originator_object = json_decode($originator);
print $originator_object->name;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.