senthil kumar
senthil kumar

Reputation: 113

How to set the user permissions for ios facebook sdk 3.2

I am upgrading facebook SDK 3.0 to 3.2. I have done the facebook login through facebook SDK 3.2 and which is working fine. I would like to execute fql to get the user's album. The below code works for get the facebook photos but not to the albums because of users permissions. I am struck on how to set the "user_photos" permission for facebook sdk 3.2. Any suggestions? Thanks in advance.

NSString *query =
@"SELECT pid, src_small, src_big, src FROM photo WHERE aid IN "
@"SELECT aid FROM album WHERE owner = me() ORDER BY created DESC LIMIT 50";

NSDictionary *queryParam =
[NSDictionary dictionaryWithObjectsAndKeys:query, @"q", nil];

[FBRequestConnection startWithGraphPath:@"/fql"
                             parameters:queryParam
                             HTTPMethod:@"GET"
                      completionHandler:^(FBRequestConnection *connection,
                                          id result,
                                          NSError *error) {
                          if (error) {
                              NSLog(@"Error: %@", [error localizedDescription]);
                          } else {
                              NSLog(@"Result: %@", result);
                          }
                      }];

Upvotes: 0

Views: 318

Answers (1)

Ran Dahan
Ran Dahan

Reputation: 415

You're saying that the above code works for getting the photos, which means that you already have the "user_photos" permission that is required to fetch the user's albums (it's the same permission for both, see Graph API documentation).

If that is really the case, you can fetch the albums easily with the following query:

SELECT aid, name, link, cover_pid 
FROM album 
WHERE owner = me() 

Otherwise, if you are really missing the permission it means you cant get the user's photos either. In that case, you will have to ask the user to reauthorize with the relevant permission. You can just call the regular FBSession authorization methods with the new permission, and it will prompt the user for it.

Anyways, I would advise you to use the Graph API Explorer to test your FQL queries, it will help you to easily recognize what is the problem.

Upvotes: 1

Related Questions