I am developing an application for iPhone that uses facebook. I need to get my data (the data of current user).
I'm sure I made the correct login and have obtained the proper permissions.
Now,
I want a NSArray with the data and make a print with NSLog oh this data.
I have made this for the friendlist and i have no problem:
-(IBAction)friendsInfo:(id)sender{
// get the logged-in user's friends
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result {
//ok so it's a dictionary with one element (key="data"), which is an array of dictionaries, each with "name" and "id" keys
items = [(NSDictionary *)result objectForKey:@"data"];
for (int i=0; i<[items count]; i++) {
NSDictionary *friend = [items objectAtIndex:i];
long long fbid = [[friend objectForKey:@"id"]longLongValue];
NSString *name = [friend objectForKey:@"name"];
NSLog(@"id: %lld - Name: %@", fbid, name);
}
}
But for my info the same method not work:
-(IBAction)myInfo:(id)sender{
// get information about the currently logged in user
[facebook requestWithGraphPath:@"me" andDelegate:self];
}
Can someone help me?
-(void)addList:(FBSession *)session {
NSString* fql = [NSString stringWithFormat:
@"select uid from user where uid == %lld", session.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
sessionView = session;
[[FBRequest requestWithDelegate:self] call:@"facebook.friends.get" params:params];
}
- (void)request:(FBRequest*)request didLoad:(id)result {
if(myList==nil) {
NSArray* users = result;
myList =[[NSArray alloc] initWithArray: users];
for(NSInteger i=0;i<[users count];i++) {
NSDictionary* user = [users objectAtIndex:i];
NSString* uid = [user objectForKey:@"uid"];
NSString* fql = [NSString stringWithFormat:
@"select name from user where uid == %@", uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
[[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
}
}
else {
NSArray* users = result;
NSDictionary* user = [users objectAtIndex:0];
NSString* name = [user objectForKey:@"name"];
txtView.text=[NSString localizedStringWithFormat:@"%@%@,\n",txtView.text,name];
}
}
use this function to get your faceBook Info (logged in user info)
- (void)fetchUserDetails {
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"SELECT uid, name, pic FROM user WHERE uid=me()", @"query",nil];
[fb requestWithMethodName:@"fql.query"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
}
-(IBAction)getMeFriendsButtonPressed:(id)sender {
FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:@"me/friends" withGetVars:nil];
NSLog(@"getMeFriendsButtonPressed: %@", fb_graph_response.htmlResponse);
NSDictionary *DictTmp = [fb_graph_response.htmlResponse JSONValue];
NSMutableArray *myFriendList=[[DictTmp objectForKey:@"data"];
}
NSString* fql = [NSString stringWithFormat:@"select uid,name from user where uid == %lld", session.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
[[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
[[FBRequest requestWithDelegate:self] call:@"facebook.friends.get" params:params];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.