簡體   English   中英

最大消息數 - Facebook PHP api

[英]Maximum message count - Facebook PHP api

我正在開發一個 facebook 應用程序,因為它是我的第一個 facebook 應用程序,所以我在 PHP API 方面遇到了一些問題。

我想獲取發送最大數量的發件人的姓名和個人資料 ID。 的消息。 我是 PHP 的新手,在獲取收件箱對象后在繼續操作時遇到問題。 任何幫助,將不勝感激。

我被困在這里

$inbox = $user_profile['inbox'];

user_profile是一個數組,其中存儲用戶的個人資料和帳戶的數據。

使用 PHP API 向線程表發出 FQL 請求。 這將為您提供發起者的 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);

適當地設置viewer_id。 注意 ORDER BY 和 LIMIT。 此 FQL 根據 message_count 為您提供前 10 名發件人。 然后,如果您需要獲取他們的名字:

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