2011-09-09 83 views
1

試圖實施我正在努力的iPhone應用程序上的Facebook牆貼。Facebook的iPhone SDK - 自動PublishSteam(旁路發佈到牆對話框)

如何繞過「貼到牆上」的對話框並直接提交?
基本上我只是想發佈一個網址,我不想讓人們看到「寫東西」文本框。

這是我迄今爲止的代碼(來自示例應用程序)。

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


[_facebook dialog:@"feed" 
     andParams:params 
    andDelegate:self]; 

謝謝
三通

回答

3

只需使用的Facebook類的- (FBRequest*)requestWith...實例方法之一。

使用舊的REST API簡單的牆後:

NSString *facebookStatusMessage = @"facebookStatusMessage"; 
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           facebookStatusMessage, @"status", 
           nil]; 

FBRequest *request = [_facebook requestWithMethodName:@"status.set" andParams:params andHttpMethod:@"POST" andDelegate:self]; 

這是更好地使用Facebook的圖形API與- (FBRequest*)requestWithGraphPath:爲REST API將得到過時。

然後也實現一些FBRequestDelegate協議:

- (void)request:(FBRequest *)request didFailWithError:(NSError *)error { 
} 

- (void)request:(FBRequest *)request didLoad:(id)result { 
    // result may be a dictionary, an array, a string, or a number, 
    // depending on the format of the API response 
}