簡體   English   中英

從Facebook得到越來越多的共同朋友

[英]Getting wrong mutual friends count from facebook

我試圖與Facebook取得共同的朋友,但這給了我錯誤的結果。 我得到的共同朋友總數的計數是正確的,但是當數據為用戶時,該數字並沒有到來

請求

https://graph.facebook.com/v2.8/1744744292507346?fields=context.fields(mutual_friends{name,picture.type(large)})&access_token=access_token

響應

{
   "context": {
      "mutual_friends": {
         "data": [
            {
               "name": "Gaurav Varshney",
               "picture": {
                  "data": {
                     "is_silhouette": false,
                     "url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p200x200/15541198_1872071033026134_3669335060573505093_n.jpg?oh=d4a95ee6cdb8d401be06e8f10fbf6d50&oe=59B0C911"
                  }
               },
               "id": "1919297771636793"
            }
         ],
         "paging": {
            "cursors": {
               "before": "MTkxOTI5Nzc3MTYzNjc5MwZDZD",
               "after": "MTkxOTI5Nzc3MTYzNjc5MwZDZD"
            }
         },
         "summary": {
            "total_count": 2
         }
      },
      "id": "dXNlcl9jb250ZAXh0OgGQHYKW1ALzRNZBAkUhMk2uDFtLZBBkzlasCZAq98zEqnPZBjqy7beHZBJZCVZB7STTw6yMnKC0w4qDA05ZBOGQ3RdRoPjfi1cbAmnChBQ1xLYpJuuKrIEZD"
   },
   "id": "1744744292507346"
}

因為total_count顯示2,所以我只有1個朋友。誰能告訴我我做錯了什么?

當嘗試擊中all_mutual_friends

https://graph.facebook.com/v2.8/1744744292507346?fields=context.fields(all_mutual_friends{name,picture.type(large)})&access_token=access_token

{
   "error": {
      "message": "(#10) To use all_mutual_friends on behalf of people who are not admins, developers and testers of your app, your use of this endpoint must be reviewed and approved by Facebook. To submit this feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review",
      "type": "OAuthException",
      "code": 10,
      "fbtrace_id": "HF3ZO8U3eLW"
   }
}

缺少有關此功能的文檔,我不得不對此進行深入研究。 主要關於如何使用Graph API進行請求。

這就是我正在做的事情,並且正在起作用,但有一些缺陷,我將在后面解釋:

假設我們在這里有UserA和UserB。 您需要收集每個用戶的context-id並將其保存在服務器端,因為以后必須使用它。

因此,UserA連接並希望與已經連接的UserB請求共同的朋友。 您需要做的是:

UserA FB Graph請求使用此:

/'{{UserB context-id}}/all_mutual_friends?limit=5000', 'get'

還發送UserA fbaccesstoken

我使用限制5000來避免對數據結果進行分頁。

現在,缺陷:

all_mutual_friends讓我有些頭疼。 當然,我可能完全錯了,但是我調試了好幾天,當功能仍處於開發模式且未由FB公開/授權時,Facebook似乎出現了一些問題。 不知道,我需要征求許可才能在生產中看到它。

在我的應用程序上,我意識到有時實際上並未列出一些common_friends,這不是腳本的錯誤,但可能是某些用戶配置避免使用此問題或某些facebook問題。 IDN。

無論如何,這就是您應該要求共同朋友的方式。

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM