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
Related
I am creating a iPhone app in which i have to show friend list with their images.
I am using Facebook graph api. i am getting the friends id and name but not the images.
So please suggest me how i can get this?
Write a FQL to get list of facebook friends & their Pics
NSString *query = #"SELECT uid,name,first_name,last_name,pic_square FROM user WHERE uid IN (";
query = [query stringByAppendingFormat:#"SELECT uid2 FROM friend WHERE uid1 = %#)",userid];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
query, #"query",
nil];
[_facebook requestWithMethodName: #"fql.query"
andParams: params
andHttpMethod: #"POST"
andDelegate:self];
you will get a array in u r
-(void)request:(FBRequest *)request didLoad:(id)result
Sample
{
"first_name" =User;
"last_name" = R;
name = "User R";
"pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/.jpg";
uid = 595sd1;
}
{},{} etc
Hope this helps!
Have a simple problem to load my friend list in table view and asynchronously load their profile-pic thumbnails. I just couldn't figure out the correct url for the thumbnail image. could anyone help me out with the url of the display pic of friends
Write a FQL to get list of facebook friends & their Pics
NSString *query = #"SELECT uid,name,first_name,last_name,pic_square FROM user WHERE uid IN (";
query = [query stringByAppendingFormat:#"SELECT uid2 FROM friend WHERE uid1 = %#)",userid];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
query, #"query",
nil];
[_facebook requestWithMethodName: #"fql.query"
andParams: params
andHttpMethod: #"POST"
andDelegate:self];
you will get a array in u r
-(void)request:(FBRequest *)request didLoad:(id)result
Sample
{
"first_name" =User;
"last_name" = R;
name = "User R";
"pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/.jpg";
uid = 595sd1;
}
{},{} etc
Hope this helps!
I am looking for some documentation or sample code on how to send multiquery fql requests to Facebook via iOS SDK.
I found some older samples but they doesnt work for me.
I have populated an NSDictionary with the queries and I try to send the request via
[[FBRequest requestWithDelegate:self] call:#"facebook.fql.multiquery" params:params];, as stated in the samples I have read, but I get an "unrecognized selector sent to class" error and I cant find the "requestWithDelegate" method in FBRequest.h either. Is it deprecated?
Some help on this would be very appreciated!
// Construct your FQL Query
NSString* fql = [NSString stringWithFormat:#"SELECT uid, name, hometown_location from user where uid IN (SELECT uid2 FROM friend WHERE uid1=%lld) and hometown_location != '' ORDER BY rand() limit 4", facebookId];
// Create a params dictionary
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:#"query"];
// Make the request
[facebook requestWithMethodName:#"fql.query" andParams:params andHttpMethod:#"GET" andDelegate:self];
The the delegate FBRequestDelegate will be call with the response. Depending on your needs, you'll do something like:
- (void)request:(FBRequest*)request didLoad:(id)result {
NSLog(#"didLoad() received result: %#", result);
}
The facebook object is created like:
Facebook * facebook = [[Facebook alloc] initWithAppId:kAppID];
More info on how to set this up can be found here:
https://developers.facebook.com/docs/guides/mobile/
And depending on your FQL query, you will need permissions from the user. See the list of permissions here:
https://developers.facebook.com/docs/authentication/permissions/
There is also a test console for FQL queries here:
https://developers.facebook.com/docs/reference/rest/fql.query/
And if you want to do an Multiquery instead of a single query, it would look like:
NSString* fql1 = [NSString stringWithFormat:
#"select uid2 from friend where uid1 == %lld order by rand() limit 10", facebookId];
NSString* fql2 = [NSString stringWithFormat:
#"select uid, name from user where uid in (select uid2 from #queryID)"];
NSString* fql3 = [NSString stringWithFormat:
#"select uid, status_id, message from status where uid in (select uid from #queryName) limit 1"];
NSString* fql = [NSString stringWithFormat:
#"{\"queryID\":\"%#\",\"queryName\":\"%#\",\"queryStatus\":\"%#\"}",fql1,fql2,fql3];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:#"queries"];
[facebook call:#"fql.multiquery" params:params];
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.
I want to retrieve the status data posted/published by friends of a user. I wrote the following code, but only get the user's own status updates. Could someone please help to tell me what's wrong with my code? Thanks!
NSString *fql = [NSString stringWithFormat:#"select uid,message from status where uid in (select uid2 from friend where uid1=%lld) order by time desc ", uid];
NSDictionary *params = [NSDictionary dictionaryWithObject:fql forKey:#"query"];
[[FBRequest requestWithDelegate:self] call:#"facebook.Status.get" params:params];
You need to change the call to use "facebook.fql.query" since you're doing a direct query.
Here's my code for getting the last 20 friends updates:
NSString* fql = [NSString stringWithFormat:
#"SELECT uid, pic_square, name, status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = %lld) AND status.time > 0 ORDER BY status.time DESC LIMIT 20", fbSession.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:#"query"];
last20FriendsStatusRequest = [FBRequest requestWithDelegate:self];
[last20FriendsStatusRequest call:#"facebook.fql.query" params:params];
Best regards,