2011-09-06 125 views
1

我想将图片和文字张贴到朋友的墙上。我不应该使用对话框,我正在使用stream.publish直接发布。 我可以成功发布到我自己的墙上(登录用户),但我需要找到一种方式发布在朋友的墙上。如何在朋友的墙上张贴图片+文字

这是我的代码,我需要有人帮助我添加几行代码发布到朋友的墙上。

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

回答

3

它看起来像你使用的是旧的API。使用较新的图形API,你可以这样做:

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

See more documentation here.

+0

现在我面临的另一个问题。你能告诉我如何张贴饲料给多个朋友吗?因为我正在使用facebookref变量的单个实例。 – Rahul

+0

发出多个请求。我没有看到任何方式发布到文档中的多个提要。 –

相关问题