我想要获取用户组并希望列出它们,但我无法从Facebook获取这些组 我能够做到
*Successful Login
*fetch friend list
*i have also allowed the permission user_groups for fetching user groups
这里我这样做是为了获取用户组
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request("me/groups", params,
new GroupsRequestListener());
public class GroupsRequestListener extends BaseRequestListener {
@Override
public void onComplete(final String response, final Object state) {
dialog.cancel();
Log.v("response", response);
Intent myIntent = new Intent(getApplicationContext(),
GroupsList.class);
myIntent.putExtra("API_RESPONSE", response);
startActivity(myIntent);
}
public void onFacebookError(FacebookError error) {
dialog.cancel();
Toast.makeText(getApplicationContext(),
"Facebook Error: " + error.getMessage(), Toast.LENGTH_SHORT)
.show();
}
}
但是我得到了一个回复,就像日志
那样06-15 07:43:19.563: V/response(645): {"error":{"message":"(#100) Unknown fields: location,birthday","type":"OAuthException","code":100}}
“我/朋友”参数可以获取好友列表。 参数“me / groups”是否适用于获取用户组?
答案 0 :(得分:3)
谢谢@Christoph Eberhardt。我在你的帮助下得到了解决方案。我犯的错误是worng请求parameters
。参数应该是
Bundle params = new Bundle();
params.putString("fields", "name");
设置请求参数后,上面的代码完美无缺。 获取用户组的完整解决方案是
//onCreate
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
Bundle params = new Bundle();
params.putString("fields", "name");
mAsyncRunner.request("me/groups", params,
new GroupsRequestListener());
//then
public class GroupsRequestListener extends BaseRequestListener {
@Override
public void onComplete(final String response, final Object state) {
dialog.cancel();
Log.v("response", response);
Intent myIntent = new Intent(getApplicationContext(),
GroupsList.class);
myIntent.putExtra("API_RESPONSE", response);
startActivity(myIntent);
}
public void onFacebookError(FacebookError error) {
dialog.cancel();
Toast.makeText(getApplicationContext(),
"Facebook Error: " + error.getMessage(), Toast.LENGTH_SHORT)
.show();
}
}
答案 1 :(得分:2)
错误指向您身边的请求参数错误。在请求您的朋友时,您可以明确请求您的朋友的生日和位置。可能群体没有这些属性。
检查您的请求参数,您应该没问题。