Facebook - “无法通过用户名查询用户"解决方案 [英] Facebook - "Cannot query users by their username" solution
问题描述
我正在开发一个安卓应用.我正在使用 HttpURLConnection 来获取 facebook 用户的个人资料图片.网址如下所示:
I am developing an android app. I was using a HttpURLConnection to get profile pictures of facebook users. The URL looks like this:
http://graph.facebook.com/?ids=username1,username2,username3&fields=picture&type=square
但是现在,由于 v2.2 不允许我获取未使用我的 Facebook 应用程序的用户的个人资料图片,因此会引发错误:
But now, since v2.2 doesn't let me to get profile pictures of users who are not using my facebook app, it throws an error:
{错误":{
"message": "(#803) Cannot query users by their username (username1)",
"type": "OAuthException",
"code": 803 } }
我对使用Android 版 Facebook SDK"不感兴趣.假设我使用弹出式 webview 来授权我的 facebook 应用程序.什么网址会让我做同样的事情?有没有像这样的简单解决方案:
I am not interested in using "Facebook SDK for Android". Let's say I use a pop-up webview to authorize my facebook app. What url would let me do the same thing? Is there a simple solution like this:
graph.facebook.com/?app=APP-ID&ids=username1,username2&fields=picture
graph.facebook.com/?app=APP-ID&ids=username1,username2&fields=picture
推荐答案
从 API 的 v2.0 开始,您根本不应该使用用户名 - 这就是您不能再通过用户名查询用户的原因.访问用户数据的唯一方法是授权该用户并使用 /me
端点.
Since v2.0 of the API, you are not supposed to use usernames at all - and that´s why you can´t query users by their username anymore. The only way to get access to data of a user is by authorizing that user and using the /me
endpoint.
主要规则:忘记未授权您的应用程序的用户,出于隐私原因,您不应获取这些用户的任何数据.
Main rule: Forget about users who did not authorize your App, you are not supposed to get any data of those for privacy reason.
这篇关于Facebook - “无法通过用户名查询用户"解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!