使用Facebook SDK 3.0 for iOS发布在朋友墙上
我想用facebook sdk 3.0在我的朋友墙上张贴消息。 所以请任何人build议我。
我也试过这个
但它没有为我工作
我认为这个代码也许工作。
NSMutableDictionary *params; params = [NSMutableDictionary dictionaryWithObjectsAndKeys: userID, @"to", msg,@"message", theUrl, @"picture", appLink, @"link", nil]; [facebook_ dialog:@"feed" andParams:params andDelegate:self];
https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/
您需要将不推荐使用的标题导入到您的项目中。 它们位于Documents / FacebookSDK / FacebookSDK.framework / Versions / A / DeprecatedHeaders中。 一旦你导入所有这些文件,你可以创build一个Facebook对象,并做其他答案说。 FB 3.0 SDK不适用于任何使用FBDialog的旧function(发送应用程序请求,发布到墙上等)。
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"facebook key", @"app_id", @"http://developers.facebook.com/docs/reference/dialogs/", @"link", @"image link", @"picture", @" ", @"description", @"", @"name", @" ", @"caption", nil]; [_facebook dialog:@"feed" andParams:params andDelegate:self]; [_facebook logout];
你不需要Facebook的身份validation。如果你不是login,而不是首先显示login屏幕和显示共享对话框。 另请参阅
对于Facebook SDK 3.0:
我正在使用下面的FBRequestConnection块来分享我的Facebook的朋友墙上的应用程序与给定的facebookid作为方法parameter.IF你想在你自己的墙上分享同样的事情只是改变
[NSString stringWithFormat:@"%@/feed",friendId]
同
@"me/feed"
-(void)postToFriendWall:(NSString*)friendId{ NSString *pictureUrl = [NSString stringWithFormat:@"http://......."]; NSMutableDictionary *postParams = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"Name", @"name", @"www.mylink.com", @"link", @"Caption Text", @"caption", @"Description Text", @"description", @"Post Message", @"message", pictureUrl, @"picture", nil]; [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed",friendId] parameters:postParams HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if (!error) { UIAlertView *postSentAlert = [[UIAlertView alloc] initWithTitle:@"Facebook" message:NSLocalizedStringFromTable(@"kFacebookPostAlertTitle", @"ContactList", "") delegate:nil cancelButtonTitle:NSLocalizedStringFromTable(@"kOK", @"ApplicationStrings", "") otherButtonTitles:nil]; [postSentAlert show]; } }