Question

I want to fetch the user groups and want to list them but I am unable to fetch the groups from Facebook, though I 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/friends" parameters is ok for fetching friend list. Is the parameter "me/groups" right for fetching user group?

Was it helpful?

Solution

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();
    }

}

OTHER TIPS

The error points to a request parameter mistake on your side. When requesting your friends, you can explicitly request the birthday and the location of your friend. Probably groups don't have those attributes.

Check your request parameters and you should be fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top