简体   繁体   English

最大消息数 - Facebook PHP api

[英]Maximum message count - Facebook PHP api

I am working on a facebook app and since its my first facebook app, I am facing some problems with the PHP API.我正在开发一个 facebook 应用程序,因为它是我的第一个 facebook 应用程序,所以我在 PHP API 方面遇到了一些问题。

I want to fetch the name and profile ID of the sender who sent maximum no.我想获取发送最大数量的发件人的姓名和个人资料 ID。 of messages.的消息。 I am new to PHP and facing problems in proceeding after getting inbox object.我是 PHP 的新手,在获取收件箱对象后在继续操作时遇到问题。 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. user_profile是一个数组,其中存储用户的个人资料和帐户的数据。

Use the PHP API to make a FQL request to the thread table.使用 PHP API 向线程表发出 FQL 请求。 This will give you the Facebook ID of the originator :这将为您提供发起者的 Facebook ID:

$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.适当地设置viewer_id。 Notice the ORDER BY and LIMIT.注意 ORDER BY 和 LIMIT。 This FQL is giving you the TOP 10 senders based on message_count.此 FQL 根据 message_count 为您提供前 10 名发件人。 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;
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM