Search code examples
c++facebookfacebook-graph-apicocos2d-x

Cocos2dx facebook invitable_friend graph api


I am trying to get friend list from facebook on cocos2dx game. But when I try, only available to get 25 friends. But in Facebook Graph API Test Site on facebook developer site, I can get more with limit paramter like the picture as below.

enter image description here

How can I implement this on Cocos2dx? The current codes are like this.

void Facebook::getFBFriends()
{
    if(fb_user_id.empty() == true) return;    
    g_vFBFriends.clear();    
    std::string path = "/me";    
    FacebookAgent::FBInfo params;
    params.insert(std::make_pair("fields", "invitable_friends"));
    FacebookAgent::getInstance()->api(path, FacebookAgent::HttpMethod::Get, params, CC_CALLBACK_2(Facebook::onGetFriendsDone, this));
}

Solution

  • "Paging" is the keyword. Without the limit parameter, you only get the first 25 entries - and a link to get the next 25 in the JSON result.

    More information: https://developers.facebook.com/docs/graph-api/using-graph-api/#paging