Aseem
Aseem

Reputation: 174

How to fetch information from facebook using FBConnect

I want to fetch user information from facebook.I am using FBConnect APi for that.

Upvotes: 0

Views: 253

Answers (3)

vishiphone
vishiphone

Reputation: 750

You should use this for FBConnect this will work for you.

  - (void)request:(FBRequest*)request didLoad:(id)result {
    if ([request.method isEqualToString:@"facebook.fql.query"]) {
    NSArray* users = result;
    NSDictionary* user = [users objectAtIndex:0];
    NSString* name = [user objectForKey:@"name"];
    self.username = name;       

    if (self.post) {
        [self postToWall];
        self.post = NO;
      }
     }
     }


 - (void)postToWall 
 {
    FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] autorelease];
    dialog.userMessagePrompt = @"Enter your message:";
    dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"Facebook Connect for iPhone\",\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\",\"caption\":\"Caption\",\"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\",\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}"];
    [dialog show];
 }

Upvotes: 1

Nikhil Bansal
Nikhil Bansal

Reputation: 1545

Try this hope it gonna help you:-

- (void)request:(FBRequest*)request didLoadRawResponse:(NSData*)data
{

    NSString *profileString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    NSMutableDictionary *userinfo = [[profileString JSONValue] mutableCopy];//1451571176

    [[NSUserDefaults standardUserDefaults] setObject:userinfo forKey:@"USER_INFO"];
    [[NSUserDefaults standardUserDefaults] synchronize];

    NSLog(@"user info:%@",userinfo);

    userDictionary = [[NSUserDefaults standardUserDefaults] valueForKey:@"USER_INFO"];
    NSString *userIDString = [NSString stringWithFormat:[userDictionary valueForKey:@"id"]];
    NSLog(@"User: %@",userIDString);
}

Hope it helps.if not then please clarify.Thanks :)

Upvotes: 0

iMash
iMash

Reputation: 1188

For fetching information from facebook you have to use FBGraph API. Hope this Link could help you.

Upvotes: 0

Related Questions