Getting a larger Facebook profile picture and personal data at a time - iphone

Please help getting a larger profile picture from Facebook. My method below returns a link to a tiny one.
- (void)openSession{
NSArray *permissions = [NSArray arrayWithObject:#"email"];
NSDictionary *parameters = [NSDictionary dictionaryWithObject:
#"picture,email,name,username,location,first_name,last_name"
forKey:#"fields"];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
if (session.isOpen) {
[FBRequestConnection startWithGraphPath:#"me" parameters:parameters
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
//save personal details using "id result"
[...saving method here...]
//manage session
[self sessionStateChanged:session state:state error:error];
}];
}
}];
}
I have also found this way: if following this link in a web browser, I can get the image larger (the bla-bla-bla is my Facebook id:)))
http://graph.facebook.com/92875029-bla-bla-bla-84538042/picture?type=large
But it looks like the link above leads to a redirect page, cos' after the image is loaded, the link is changed to :
http://profile.ak.fbcdn.net/hprofile-ak-snc6/1864-bla-bla-bbla-bla482_n.jpg
Well, never mind, I cannot use it in my method above anyway.
So actually I am getting the profile picture, but as I said, it's small.
Please help getting it larger, but within my used method. Many thanks in advance

Change your parameters to:
#"picture.type(large),email,name,username,location,first_name,last_name"

Related

Getting weird FBSDKLog

I've created App from https://developers.facebook.com/apps, I'm getting weird error like > FBSDKLog: FBSession: a permission request for publish or manage permissions contains unexpected read permissions
1. My Xcode Bundle ID matches with current Fb App 2. I'm using my App to publish Check Ins to my Friends
I've given permissions to Publish Check Ins are as below code
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"public_profile",
#"basic_info",
#"user_friends",
#"status_update",
#"publish_actions",
#"publish_checkins",
#"user_checkins",
nil];
[FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error)
Any Help will be appreciated -I'll provide more information if it's needed Thanks..
You will need to separate your request for read permissions from write permissions and request them from the user in that order.
To request read permissions:
[FBSession openActiveSessionWithReadPermissions:#[#"basic_info", #"user_checkin"]
allowLoginUI:YES
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
To request write permissions:
[[FBSession activeSession] requestNewPublishPermissions:#[#"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
}];
You can read more about the new process in Facebook iOS SDK Upgrade Guide; specifically, read the section, Asking for Read & Write Permissions Separately.

ERROR (com.facebook.sdk error 5.) in ios

In my project i am not posting anything only fetching different data from FaceBook.
some times i am getting the data but
most of the time i am getting this Error
The operation couldn’t be completed. (com.facebook.sdk error 5.)
my small code is
permissions = [[NSArray alloc] initWithObjects:#"user_friends",#"read_stream",
#"read_requests",#"user_birthday",#"user_about_me",#"user_hometown",
#"user_location",#"user_likes",#"email",
nil];
[FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
NSString *queryNew55 = #"SELECT post_id,fromid,time FROM comment WHERE time > 1375553100 AND post_id IN (SELECT post_id FROM stream WHERE source_id = me())";
// Set up the query parameter
NSDictionary *queryParam15 = #{ #"q": queryNew55 };
// Make the API request that uses FQL
[FBRequestConnection startWithGraphPath:#"/fql"
parameters:queryParam15
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(#"Error in comment query");
NSLog(#"Error: %#", [error localizedDescription]);
} else {
NSLog(#"comments Result: %#", result);
}
}
];
}];
I seen lots of thing on google on the same Error
and i applied that too but nothings works permanently.
in FaceBook App All the things like sandbox mode is off and bundle id are set perfectly.
any help like link or code or any thing related to this will be great Help.
I know this question is old, but my answer might help some other people.
I was getting this error after following some of their code/tutorials/documentation.
It seems there is a disconnect between their documentation and some of the sample code.
using
if (FBSession.activeSession.state != FBSessionStateCreated) {
// Create a new, logged out session.
self.facebookSession = [[FBSession alloc] init];
}
and
[self.facebookSession openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
will not result in the session being updated in
FBSession.activeSession
getting updated.
So you will have a session that is open (self.facebookSession) and a session that is crated&TokenLoaded - which is not open.
So making any calls like:
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
will fail as the FBRequestConnection uses FBSession.activeSession
So in the completion handler you can see the active session if you are going to manage the session your self.
[self.facebookSession openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
[FBSession setActiveSession:session];
// post or load user data.
}];
It seems to work for me now,
hope this helps

FQL query with v3.1 Facebook SDK for iOS to get birthday and email

Can anyone help me. I cannot figure out how to make a single FQL query using the latest Facebook SDK (v 3.1) for iOS to get birthday and email of user's friend. When I query for fields like name i get the correct value but get null for email and birthday field.
Here is my code
- (void)facebookViewControllerDoneWasPressed:(id)sender {
// we pick up the users from the selection, and create a string that we use to update the text view
// at the bottom of the display; note that self.selection is a property inherited from our base class
for (id<FBGraphUser> user in _friendPickerController.selection) {
_nameTxt.text = user.name;
NSString *fql = [NSString stringWithFormat:#"SELECT email, birthday, name FROM user WHERE uid = %# ",user.id];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:fql forKey:#"q"];
[FBRequestConnection startWithGraphPath:#"/fql"
parameters:params
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(#"Error: %#", [error localizedDescription]);
} else {
NSLog(#"Result: %#", result);
}
}];
}
[self.navigationController dismissModalViewControllerAnimated:YES];
}
I'm getting value for name but null for email and birthday.
Thanks
Before you call your query, you'll need to have the user log in and ask for email and user_birthday permissions. For example:
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"email",
#"user_birthday",
nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
}
The above method is used in the context of this tutorial:
https://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/
Also check out the FQL tutorial:
https://developers.facebook.com/docs/howtos/run-fql-queries-ios-sdk/

iOS 6.0 Facebook SDK permissions, can't get gender of the user

I have quick question:
this code snippet works:
NSArray *permissions = #[#"email", #"user_birthday"];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
And this doesn't:
NSArray *permissions = #[#"email", #"user_birthday", #"gender"];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
I'm simply asking for the gender of the Facebook user and in first case I've got on my NSLog console: User session found which is great... but when I extend the permission and include gender in it, I've got UIAlertView with:
Error
The operation couldn't be completed. (com.facebook.sdk error 2.)
What I am doing wrong? How to ask for permission to get user gender?
As you can see here, the gender is part of the basic informations.
And whenever you open a session with permissions, it will ask for basic informations.
Since you already have it, facebook musts consider it as an error.
I had the same issue when asking for the username by the way.
Gender is not a public property of , so, you can't access using user.gender, as you do with user.name, here you have a dictionary and you access passing the Key.
like:
_genderLabel.text = [user objectForKey:#"gender"];
Cheers
Look at the list of permissions - gender is not one of them - gender is, however a field of the User object and is also exposed in the sex column in the user FQL table which you can access once the user has granted you the basic permission to access their data.
A sample query (SDK agnostic) to return just the current user's gender is simply
/me?fields=gender, the return value of which will be
{
"gender": "male",
"id": "533875325"
}
Note that it's also returned in the default response when accessing a user, so you don't need to specify it explicitly.
Also, some users may not have a gender defined (though i think this is relatively rare)

Facebook Graph API for iOS search

I am trying to search places from the GraphAPI using following code without luck. Can anybody please enlight my path ?
If I try to post link/message/photo it works as expected but when trying to get location it always fails and gives me **The operation couldn’t be completed. (facebookErrDomain error 10000.)**
//Following statement is using permissions
NSArray * permissions = [NSArray arrayWithObjects:#"publish_stream",#"user_checkins", #"friends_checkins", #"publish_checkins", nil];
[facebook authorize:FB_APP_ID permissions:permissions delegate:_delegate];
NSString *centerString = [NSString stringWithFormat: #"%f,%f", 37.76,-122.427];
NSString *graphPath = #"search";
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"coffee",#"q",
#"place",#"type",
centerString,#"center",
#"1000",#"distance", // In Meters (1000m = 0.62mi)
nil];
[facebook requestWithGraphPath:_path andParams:_params andHttpMethod:#"POST" andDelegate:_delegate];
Never mind. Downloaded latest sample HackBook from facebook for graph api from github and it includes sample code for the same.
For "search" you should use "GET" instead of "POST".
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#search
With Facebook iOS SDK, you can use FBRequestConnection after login.
[FBRequestConnection startWithGraphPath:#"search?q=coffee&type=place&center=37.76,-122.427&distance=1000"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Sucess! Include your code to handle the results here
NSLog(#"result: %#", result);
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"error: %#", error);
}
}];
With Last SDK
NSMutableDictionary *params2 = [NSMutableDictionary dictionaryWithCapacity:3L];
[params2 setObject:#"37.416382,-122.152659" forKey:#"center"];
[params2 setObject:#"place" forKey:#"type"];
[params2 setObject:#"1000" forKey:#"distance"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:#"/search" parameters:params2 HTTPMethod:#"GET"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
NSLog(#"RESPONSE!!! /search");
NSLog(#"result %#",result);
NSLog(#"error %#",error);
}];