0
我在我的一个应用程序中使用FacebookSDK登录到应用程序并共享一些内容。登录完成后,我现在可以使用此SDK登录到应用程序。以下是我用于登录的代码。使用FacebookSDK从iOS应用程序发布到Facebook
-(void)didSelectLoginWithFB
{
if (FBSession.activeSession.isOpen) {
[appDelegate closeSession];
}
else {
[appDelegate openSessionWithAllowLoginUI:YES];
}
if(FBSession.activeSession.accessToken){
[self performSelector:@selector(FBLoginAction) withObject:nil];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(FBLoginDidFinish:)
name:@"FBLoginDidFinish"
object:appDelegate];
}
-(void)FBLoginDidFinish:(NSNotification *)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self performSelector:@selector(FBLoginAction) withObject:nil];
}
-(void)FBLoginAction
{
if (FBSession.activeSession.isOpen) {
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *user,
NSError *error) {
if (!error) {
NSDictionary *userInfo = (NSDictionary *)user;
NSLog(@"User dic %@",userInfo);
// fbUserId = user.id;
// NSLog(@"User dic %@",fbUserId);
userMail = [userInfo objectForKey:@"email"];
NSLog(@"User E Mail --- %@", userMail);
loginFlag = 200;
[self getDataFromServer:nil];
}
else{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Facebook Connection Error !!" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil ];
[alert show];
}
}];
}
}
现在,我想发布一些东西到用户的facebook墙(时间线)。我如何使用此SDK来做到这一点?我没有从这个sdk的developer.facebook.com获得任何信息。 请帮忙!