Reputation: 654
I am currently doing an app, in which I need to make the user select one of the Facebook pages from the list of facebook pages the user manages.
I searched and found that, we are able to search the pages by name, but that includes the whole pages in Facebook. I just need the pages that I manage.
Update:
I gave the /me/accounts for getting the pages that I manage. But the resulting data that i get is
2014-05-14 10:22:11.519 fb page[1695:60b] { data = ( ); }
Here is my code:
[FBRequestConnection startWithGraphPath:@"me/accounts"
parameters:nil
HTTPMethod:@"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
if (!error)
{
NSLog(@"%@",result);
NSDictionary *dict = result;
pagesArray = [dict objectForKey:@"data"];
NSLog(@"%uld", pagesArray.count);
if (pagesArray.count == 0)
{
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"No pages Found" message:@"You do not manage any pages" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
else{
facebookPageId = [[pagesArray objectAtIndex:0] objectForKey:@"id"];
NSLog(@"%@", facebookPageId);
[self getPage];
[self getPagePosts];
}
}
else
NSLog(@"%@", [error localizedDescription]);
/* handle the result */
}];
I also gave the login permission, like this:
self.loginView.publishPermissions = @[@"manage_pages"];
I also get this warning:
FBSDKLog: FBSession: a permission request for publish or manage permissions contains unexpected read permissions
Upvotes: 0
Views: 689
Reputation: 40028
Take a look at Graph API Reference.
/{user-id}/accounts
returns Facebook pages of which the current user is an admin.
A user access token with manage_pages
permission is required, and will only allow the retrieval for that specific person.
You can also try:
/{user-id}/applications/developer/
to get list of apps managed by the user.
Upvotes: 1