简体   繁体   中英

How to Post An Image+ Text on friend's wall

I am trying to post an image and a text to a friend's wall. I am not supposed to use the dialog box, I am using stream.publish to post directly. I can successfully post it to my own wall ( The logged in user), but I need to find a way to post on friend's wall.

Here is my code I need someone to help me add to few lines of code to post to friend's wall.

/*
Friends URL To whom's wall I need to post. 
 **I need to figure out how to use friendURL in my code. 
So that post goes to my    friend's wall.
Below code is posting to my own  wall.**

*/ 
NSString *friendURL = [NSString stringWithFormat:
                              @"http://www.facebook.com/profile.php?id=%@",
                              marriedFriend.userID];
SBJSON *jsonWriter = [[SBJSON new] autorelease];

NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary 
                                                       dictionaryWithObjectsAndKeys: @"Always Running",@"text",@"http://itsti.me/",
                                                       @"href", nil], nil];

NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary 
dictionaryWithObjectsAndKeys:
                            @"a long run by Rahul...", @"name",
                            @"The Facebook Running app", @"caption",
                            @"it is fun", @"description",
                            @"http://itsti.me/", @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary
                               dictionaryWithObjectsAndKeys:
                               @"Share on Facebook",  @"user_message_prompt",
                               actionLinksStr, @"action_links",
                               attachmentStr, @"attachment",
                               nil];



[facebookRef  requestWithMethodName:@"stream.publish" andParams:params andHttpMethod:@"POST" andDelegate:self];

It looks like you are using the old API. Using the newer Graph API you can do:

// replace PROFILE_ID with your friend's ID
[facebookRef requestWithGraphPath:@"PROFILE_ID/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];

See more documentation here.

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