问题描述
我想获取用户组并列出他们,但是我无法从Facebook上获取组.我能够做到
I want to fetch the user groups and want to list them but I am unable to fetch the groups from Facebook, thoughI am able to do
*Successful Login
*fetch friend list
*i have also allowed the permission user_groups for fetching user groups
在这里,我这样做是为了获取用户组
here I am doing like this for fetching user group
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();
}
}
但是我得到了回应,类似这样的日志
But I got a response, something like this on log
06-15 07:43:19.563: V/response(645): {"error":{"message":"(#100) Unknown fields: location,birthday","type":"OAuthException","code":100}}
我/朋友"参数可用于获取朋友列表.参数"me/groups"是否适合获取用户组?
"me/friends" parameters is ok for fetching friend list.Is the parameter "me/groups" right for fetching user group?
推荐答案
感谢@Christoph Eberhardt.我在您的帮助下得到了解决方案.我正在做的错误是wearg请求parameters
.参数应该是
Thanks @Christoph Eberhardt. i got the solution with your help. what i was doing mistake is the worng request parameters
. the params should be
Bundle params = new Bundle();
params.putString("fields", "name");
设置请求参数后,以上代码可完美运行.提取用户组的完整解决方案是
after setting request params,above code works perfectly.The complete solution for fetching user group is
//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();
}
}
这篇关于使用Facebook API从Facebook获取用户组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!