Search code examples
iosfacebookfacebook-graph-apifacebook-fqlfacebook-ios-sdk

Using my FacebookAppID did not work in iOS


I want to use Facebook Api to get Facebook friends list. So, I create new app on Facebook and got AppID and give Bundle ID when I use that AppID and Bundle ID in my native iOS app and use api to get all friends list it get empty friend list.

And if I use the App ID of "SendRequestHowTo" sample project it get all friend list of login user. Tell me how to configure my new app on Facebook Developer site to get friend list.

My code for get friends list:

// Query to fetch the active user's friends, limit to 25.
    NSString *query =
    @"SELECT uid, name, pic_square FROM user WHERE uid IN "
    @"(SELECT uid2 FROM friend WHERE uid1 = me())";
    // Set up the query parameter
    NSDictionary *queryParam = @{ @"q": query };
    // Make the API request that uses FQL
    [FBRequestConnection startWithGraphPath:@"/fql"
                                 parameters:queryParam
                                 HTTPMethod:@"GET"
                          completionHandler:^(FBRequestConnection *connection,
                                              id result,
                                              NSError *error) {
                              if (error) {
                                  NSLog(@"Error: %@", [error localizedDescription]);
                              } else {
                                  _friends_list = (NSArray *) result[@"data"];
                                  NSLog(@"Result: %@", result);

                                  [self getLetsWalkeeFriendList];

                                  // Sort Table Data
                                  [self sortTableView];
//                                  [_tbl_view_friends reloadData];
                              }
                              [self.view setUserInteractionEnabled:YES];
//                              [self.view hideToastActivity];
                          }]; 

Using Sample project AppID (i.e FacebookAppID: 403223126407920 and Bundle identifer: com.facebook.samples.SendRequestsHowTo). When I login with facebook I got output

Result: {
    data =     (
                {
            name = "Assad Sarwar";
            "pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpa1/t1.0-1/c153.5.545.545/s50x50/1978738_766566543368250_230425531_n.jpg";
            uid = 100000447351759;
        },
                {
            name = "Muhammad Hassan Butt";
            "pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xap1/t1.0-1/c0.0.50.50/p50x50/10167970_873047696055100_7845811348955741805_n.jpg";
            uid = 100000496339789;
        },
                {
            name = "Umair Jafar";
            "pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/t1.0-1/c0.2.50.50/p50x50/10500337_910092152350902_4827832642500691993_n.jpg";
            uid = 100000503784242;
        }, .........
)
}

and when I used my AppID which is provided by facebook and using same user for login to facebook, I got output like

 Result: {
            data =     ( )
    }

Solution

  • For apps created after April 30th 2014, the endpoint /me/friends will only return a list of friends that also use your app. See the Platform Upgrade Guide [1].

    [1] https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids