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

时间:2012-08-27 08:11:39

标签: iphone ios facebook

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

我也试过this

但它对我不起作用

4 个答案:

答案 0 :(得分:1)

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

NSMutableDictionary *params;
params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               userID,  @"to",
                               msg,@"message",
                               theUrl, @"picture",
                               appLink, @"link",
                               nil];

[facebook_ dialog:@"feed"
        andParams:params
      andDelegate:self];

答案 1 :(得分:1)

https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/

您需要将已弃用的标头导入项目中。它们位于Documents / FacebookSDK / FacebookSDK.framework / Versions / A / DeprecatedHeaders中。导入所有这些文件后,您可以创建一个facebook对象并执行其他答案所说的内容。 FB 3.0 SDK不适用于使用FBDialog的任何旧功能(发送应用程序请求,发布到您的墙上等)。

答案 2 :(得分:0)

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

答案 3 :(得分:0)

对于Facebook SDK 3.0:

我正在使用以下FBRequestConnection块在我的脸书朋友墙上与给定的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];

     }
}