2016-11-21 34 views
-1

我建立一個Rails後端爲iOS應用。後端需要與Facebook接口來抓取和使用每個用戶的Facebook好友。Facebook好友請求返回空 - 儘管權限

但Facebook的「朋友」的請求返回空。

我從根本上讓下列要求:

curl https://graph.facebook.com/[FILTERED_USER_ID_FOR_APP]?fields=friends&access_token=[FILTERED]&debug=all 

我已經看了關於這個StackOverflow的每噸職位(this onethis one,和this one,更多),但還沒有找到一個相同的問題或適合的解決方案。

我似乎有正確設置權限。無論是在Rails應用程序還是用戶通過iPhone應用程序進行身份驗證時,我已將user_friends設置爲其中一個權限,實際上,當有人現在註冊時,會要求他們確定用戶朋友的權限。

但是當我真正要求他們的朋友,我得到一個迴應,告訴我有許多朋友,但沒有返回任何他們。以下回復是針對絕對是在應用上有好友的用戶。

{ 
    "data":[], 
    "summary": { 
    "total_count": 419 
    }, 
    "__debug__": { 
    "messages": [ 
     { 
     "link": "https:\/\/developers.facebook.com\/docs\/apps\/versions\/", 
     "message": "No API version was specified. This request defaulted to version v2.7.","type":"warning" 
     },   
     { 
     "link": "https:\/\/developers.facebook.com\/docs\/apps\/changelog#v2_0", 
     "message": "Only friends who installed this app are returned in API v2.0 and higher. total_count in summary represents the total number of friends, including those who haven't installed the app.", 
     "type": "info" 
     } 
    ] 
    } 
} 

什麼是令人費解的我是一)應用程序ID /用戶ID /訪問令牌似乎是正確的,因爲我可以得到基本的個人資料信息,並B)我做得到一個錯誤告訴我該請求沒有適當的權限。如果我做了類似的請求沒有權限上the explorer,它返回一個相關的調試注:

{ 
    "message": "The field 'friends' is only accessible on the User object after the user grants the 'user_friends' permission.", 
    "type": "warning" 
    } 

如果我讓在資源管理器中正確的權限,它返回的朋友列表(data陣列)。

所以它似乎是一個權限問題,但請求返回一個空的朋友列表。有任何想法嗎?

+2

你確定你已經解釋了這個? http://stackoverflow.com/questions/23417356/facebook-graph-api-v2-0-me-friends-returns-empty-or-only-friends-who-also-u – Igy

回答

2

隨着卵黃抗體的幫助(指着this answer),我找到了具體回答我的問題,這似乎值得加入這裏。

的問題是,新的2.0+版本的API只返回朋友:

  1. 誰是在應用
  2. 誰已同意user_friends權限本身。

1已全部解決,但由於我仍在測試應用程序,並且沒有人接受權限,所以我的測試用戶是唯一已接受權限的人。沒有人接受user_friends,所以沒有人作爲測試用戶的朋友出現。讓測試用戶的朋友添加權限修復問題,並將該朋友添加到返回的朋友列表中。