2012-08-08 57 views
0

我需要以某種方式獲得使用同一個應用程序的朋友之間的共享喜歡,一些FQL,最終返回給我一個最常見的喜歡列表,這可能嗎?Facebook API獲得共享朋友喜歡與安裝相同的應用程序

謝謝。

+0

我可以安裝了相同的應用程序的用戶,所以我需要如何加入這個列表用戶獲得共享的喜歡︰SELECT uid FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())AND is_app_user = 1 – ssola 2012-08-08 09:34:32

回答

0

我已經看過這個,並且基於可索引user_id字段獲取當前用戶的喜歡,您需要爲當前用戶提供user_access標記。

https://developers.facebook.com/docs/reference/fql/like/

什麼這基本上意味着是,在特定的時間可以查詢根據自己喜歡的信息您的應用程序只有當前用戶。類似下面的查詢可能適用於您。請注意,您所需要的read_stream許可

select object_id, user_id,object_type FROM like WHERE object_id in(SELECT object_id FROM like WHERE user_id =me()) and user_id in(select uid FROM user WHERE uid in(SELECT uid2 FROM friend where uid1 = me()) and is_app_user='true') 

你可以在

https://developers.facebook.com/tools/explorer/433871385166/?fql=select%20object_id%2C%20user_id%2Cobject_type%20FROM%20like%20WHERE%20object_id%20in(SELECT%20object_id%20FROM%20like%20WHERE%20user_id%20%3Dme())%20and%20user_id%20in(select%20uid%20FROM%20user%20WHERE%20uid%20in(SELECT%20uid2%20FROM%20friend%20where%20uid1%20%3D%20me())%20and%20is_app_user%3D'true') 

嘗試了這一點你會那麼最有可能需要使用一些服務器端代碼來分析返回的數據來計算什麼是最流行。可能通過創建一個數組,循環遍歷數據,檢查數組中是否有一個基於object_id的鍵,如果沒有將該鍵添加到數組中,值爲1(其中1是計數),否則增加1。

值僞代碼示例

$data; // This would be what was returned from your FQL query 
    $compare = array(); 
    foreach($data as $value){ 
    if(array_key_exists($value['object_id'],$compare)){ 
     $compare['object_id'] = $value['object_id'] + 1; 
    }else{ 
     $compare['object_id'] = 1; 
    } 
    } 
    // Do some sorting function to compare the counts. 
    //you would then probably need to batch queries to get the name/title of the object that the user has liked 

我希望這給你一個很好的起點

相關問題