简体   繁体   中英

Post on friends wall using Facebook SDK 3.0 for iOS

I want to post a message on my friends wall using facebook sdk 3.0. So please can any one suggest me.

I have also tried this

But its not worked for me

I think this code maybe work.

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/

You need to import the deprecated headers into your project. They are located in Documents/FacebookSDK/FacebookSDK.framework/Versions/A/DeprecatedHeaders. Once you import all these files, you can create a facebook object and do what the other answers are saying. FB 3.0 SDK does not work for any of the old features that used FBDialog (sending app requests, posting to your wall, etc).

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

you no need to facebook authentication.if you are not login than first show login screen and than show share dialog. Also refer

For Facebook SDK 3.0:

I am using the following FBRequestConnection block to share my app on my facebook friends wall with the given facebookid as method parameter.IF you want to share the same thing on you own wall just change the

 [NSString stringWithFormat:@"%@/feed",friendId] 

with

 @"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];

     }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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