繁体   English   中英

使用Facebook SDK 3.0 for iOS在朋友墙上发布

[英]Post on friends wall using Facebook SDK 3.0 for iOS

我想使用facebook sdk 3.0在我的朋友墙上发布消息。 所以任何人都可以建议我。

我也尝试过这个

但它不适合我

我认为这段代码可能有用。

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中。 导入所有这些文件后,您可以创建一个facebook对象并执行其他答案所说的内容。 FB 3.0 SDK不适用于使用FBDialog的任何旧功能(发送应用程序请求,发布到您的墙上等)。

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身份验证。如果你没有登录而不是第一次显示登录屏幕而不是显示共享对话框。 还请参考

对于Facebook SDK 3.0:

我正在使用以下FBRequestConnection块在我的facebook朋友墙上与给定的facebookid作为方法参数共享我的应用。你想在你自己的墙上分享同样的东西只是改变

 [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];

     }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM