android - 适用于 Android 的 Facebook API : how to get extended info regarding user`s friends?

标签 android facebook-graph-api

我正在开发小型 Android 应用程序,试图添加 Facebook 支持。

主要问题:我只能获取有关用户好友(ID、姓名)的基本信息。 应用权限列表(offline_access 仅供测试,即将移除):

 String[] sPermissions = { "friends_about_me"
                         , "friends_birthday"
                         , "friends_location"
                         , "friends_website"
                         , "offline_access" };
 mLoginButton.init(this, mFacebook,  sPermissions);

以下请求工作正常 - 返回一个 id:name 对列表,

 mAsyncRunner.request("me/friends", new SampleRequestListener());

但如果我更改它以获得更多信息

 mAsyncRunner.request("me/friends?fields=id,name,birthday,hometown", new SampleRequestListener());

服务器返回错误“必须使用 Activity 访问 token 来查询有关当前用户的信息。” 我使用浏览器测试了这些 Graph API 请求 - 它们都按预期工作。

小提示:我正在使用默认的调试证书来签署应用程序,并根据 Facebook 指令将其哈希添加为 Facebook 应用程序哈希:

Register your application's Android key hash. This is used by Facebook to ensure that another app can't impersonate your app when talking to the Facebook Android app.

Generate the key hash:

keytool -exportcert -alias [alias] -keystore [keystore] | openssl sha1 -binary | openssl base64 In the Facebook developer settings, go to the Mobile and Devices tab.

In the Android section, enter the key hash in the Key Hash field.

也许还有另一种获取用户 friend 信息(生日、位置、性别等)的方法?

最佳答案

使用

mFacebook.request(graphpath, bundle);

方法, Bundle 会有这样的参数

graphpath = "me/friends"
bundle.putString("fields","birthday");

并调用上面的请求方法,它会给你生日,但你必须添加 friends_birthday 权限。

关于android - 适用于 Android 的 Facebook API : how to get extended info regarding user`s friends?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4628822/

相关文章:

android - 为什么填充这个数组会出现段错误?

带有 Zendesk SDK 的 Android 应用程序因 java 崩溃而没有此类字段错误

android - 使用 Android 数据绑定(bind)将列表类型导入 xml 文件时出错

Android - onTabSelected 第一次没有调用 customView

php - Facebook 图形 API 循环通过分页

java - 清除全局 ArrayList 也会清除另一个

android - Facebook 登录权限对话框中未显示生日范围

Android 将图像上传到用户 Facebook 墙

Facebook 图形 API - 一些页面返回空数据集

facebook - Facebook 搜索距离参数的单位是什么?