开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜