2011-09-06 124 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

發出多個請求。我沒有看到任何方式發佈到文檔中的多個提要。 –

相關問題