Calling Facebook API method from iPhone SDK - iphone

I got Facebook Connect working and all and it's loading up the user's friends list with perfection. So now I have the logged in user's UID and the friend's UID. How would I go about calling their users.getInfo method from the SDK? The example below is what they give me to set a status, but I don't know how I can transform it to work with what I need. Especially the NSDictionary part. Please help!
Example Code -
NSString *statusString = exampleTextField.text;
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
statusString, #"status",
#"true", #"status_includes_verb",
nil];
[[FBRequest requestWithDelegate:self] call:#"facebook.Users.setStatus" params:params];
Thanks for any help!

According to the documentation at http://github.com/facebook/facebook-iphone-sdk you have to use the old API calls and the Facebook Query Language (fql) to pull information via the SDK. So you'd have to identify what information you want (or pull in a bunch and separate).
Here's the example they give to pull a user's name.
- (void)getUserName {
NSString* fql = #"select name from user where uid == 1234";
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:#"query"];
[[FBRequest requestWithDelegate:self] call:#"facebook.fql.query" params:params];
}
- (void)request:(FBRequest*)request didLoad:(id)result {
NSArray* users = result;
NSDictionary* user = [users objectAtIndex:0];
NSString* name = [user objectForKey:#"name"];
NSLog(#"Query returned %#", name);
}
getUserName shows you the data pull which you could adapt to create new routines--but the request:didLoad: function would need some internal switching.

Related

FBConnect Deprecated Endpoint Error

I am doing facebook integration part in my project. I downloaded facebook integration sample project from rey wenderlich and then changed appkey and appsecretkey. When I run this app, login validation is working fine and then it shows error.this comes in the same popup after login .
Error: This endpoint has been deprecated. To temporarily reenable it,you may disable the “august_2012” platform migration.I will be permanently disabled on August 1 ,2012
How to fix this error
The functionality I am using is the same of the FbConnect sample code
- (void)session:(FBSession*)session didLogin:(FBUID)uid {
self.usersession =session;
NSLog(#"User with id %lld logged in.", uid);
[self getFacebookName];
}
- (void)getFacebookName {
NSString* fql = [NSString stringWithFormat:
#"select uid,name from user where uid == %lld", self.usersession.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:#"query"];
[[FBRequest requestWithDelegate:self] call:#"facebook.fql.query" params:params];
self.post=YES;
}
This has a nice documentation with examples

get twitter friends using my specific app

I am integrating twitter api on iphone device with specific application. I want to get list of followers using the same app.
Is it possible to get list of followers who are using the same app?
Thanks,
Jim.
Use this api call in your twitter api to get your followers in twitter
- (NSString *)getFollowersIncludingCurrentStatus:(BOOL)flag
{
NSString *path = [NSString stringWithFormat:#"statuses/followers.%#", API_FORMAT];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
if (!flag) {
[params setObject:#"true" forKey:#"lite"]; // slightly bizarre, but correct.
}
return [self _sendRequestWithMethod:nil path:path queryParameters:params body:nil
requestType:MGTwitterFollowerUpdatesRequest
responseType:MGTwitterUsers];
}

iPhone FaceBook Connect returns NULL email if not shared

I have integrated facebook connect into my Xcode 4 project for an iPhone. Here is the code for iPhone FBconnec. FBconnect.h and FBSession.h already included.
- (void)viewDidLoad{ _session = [[FBSession sessionForApplication:#"APPKey"
secret:#"APPSecret"
delegate:self]retain];
FBLoginButton* fbButton = [[[FBLoginButton alloc] init] autorelease];
fbButton.frame = CGRectMake(228, 50, 85, 50);
[self.view addSubview:fbButton]; }
The code is working fine, but for some facebook accounts when run the FQL query to select email from user. I get NULL as shown below
length of users Array: (
{
"contact_email" = "<null>";
email = "<null>";
"first_name" = Ali;
"last_name" = Subhani;
uid = 696377693;
}
How can I get the extended permission. I am just using following code to run the query. Which contains word params, I think it has to do something with FBRequest. Have a look at the code below
- (void)getFacebookName {
//==================== MAKING FACEBOOK REQUEST =============================
NSString* fql = [NSString stringWithFormat:
#"select uid,first_name,last_name,email from user where uid == %lld",
self._session.uid];
NSDictionary* params =
[NSDictionary dictionaryWithObject:fql
forKey:#"query"];
[[FBRequest requestWithDelegate:self]
call:#"facebook.fql.query" params:params];}
Where should I enter extended permissions so I can get user email.
Thanks.
I use
[appDelegate.facebook authorize:
[NSArray arrayWithObjects:
#"offline_access", #"email", #"user_checkins", #"publish_checkins", nil]
delegate:delegate
localAppId:localAppId];
...to authorize and request email access (using the #"email" permissions key above). I'm not sure if a user can have NO email address, as they have at least one to login with.
However, Facebook gives the user the option to obfuscate it from you with an arbitrary #facebook.com account that forwards to their regular email account.

Form of fbrequest

I'm using fbconnect in my app to connect to Facebook. Whenever i code a feature, I must google to find the form like below:
//////
NSString *event = #"{\"name\":\"A party\",\"start_time\":\"1215929160\",\"end_time\":\"1215929160\",\"location\":\"Somewhere\"}";
NSDictionary *params = [NSDictionary dictionaryWithObject:event forKey:#"event_info"];
[[FBRequest requestWithDelegate:self] call:#"facebook.events.create" params:params];
/////
I wonder how can I know the format of string "event", or key #"event_info", or #"facebook.events.create". I try to find document of fbconnect that talk about format above but ... Anybody can help me about this. Thanks
It's here:
events.create

FaceBook FQL issue while extracting album name in Iphone

I have 3 albums in my Face Book account.
profile
NaturePhoto
Profile Pictures
when i use below FQL Query the "request:didLoad:" delegate return the empty array.
NSString* fql =[NSString stringWithFormat:#"SELECT cover_pid,name FROM album WHERE owner == %lld", session.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:#"query"];
[[FBRequest requestWithDelegate:self] call:#"facebook.fql.query" params:params];
I am really struck in Face book FQL.
It should be = not ==
A query for the current authenticated user would be
SELECT cover_pid,name FROM album WHERE owner = me()
Which returns a correct response