1

I'd like to get the Facebook id from ShareKit anyone have any idea? There's this reference but I still dont get it. Reference

TIA

2 Answers 2

1

I got this by using the request:-

Facebook *facebook = [[Facebook alloc] initWithAppId:SHKCONFIG(facebookAppId) 
                                     urlSchemeSuffix:SHKCONFIG(facebookLocalAppId) 
                                         andDelegate:nil];
// ... do authorization stuff

// when authorized...
[facebook requestWithGraphPath:@"me" andDelegate:self];

and implementing the delegate callback in the same file:-

- (void)request:(FBRequest *)request didLoad:(id)result
{
    NSString *fbid = [result objectForKey:@"id"];
    NSLog( @"facebook ID %@", fbid );
}

This does work, but I've no idea if this is the recommended technique, since it's the first time I've used sharekit. It seems odd to me the singleton method [SHKFacebook facebook] is private and you have to instantiate an object yourself.

0
1

ShareKit has a built in method for this:

[SHKFacebook getUserInfo];

I prefer calling it using my own member variable and checking return values inside of SHKShareDelegate callback:

SHKItem *item = [[[SHKItem alloc] init] autorelease];
item.shareType = SHKShareTypeUserInfo;
[self.shkFacebook setItem:item];
[self.shkFacebook share];

Here is the callback into delegate method shareFinishedSending():

if ([sharer isEqual:self.shkFacebook] &&
    sharer.item.shareType == SHKShareTypeUserInfo) {
    NSDictionary *facebookUserInfo = [[NSUserDefaults standardUserDefaults] objectForKey:@"kSHKFacebookUserInfo"];
    NSLog(@"id: %@", [facebookUserInfo objectForKey:@"id"]);
    NSLog(@"name: %@ %@", [facebookUserInfo objectForKey:@"first_name"], [facebookUserInfo objectForKey:@"last_name"]);
    NSLog(@"email: %@", [facebookUserInfo objectForKey:@"email"]);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.