0

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

Aseem
  • 174
  • 2
  • 10
  • I am also try with FBConnect it have litte bit problem withcustom button so my suggestion you try with FBGraph. – vishiphone May 03 '12 at 06:07

3 Answers3

1

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];
 }
vishiphone
  • 750
  • 7
  • 14
0

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

iMash
  • 1,178
  • 1
  • 12
  • 33
0

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 :)

Nikhil Bansal
  • 1,545
  • 13
  • 29