2010-12-20 105 views
1

我正在嘗試將facebook集成到我的應用程序中。我已經完成了登錄代碼並嘗試發佈在我的牆上,但我不需要facebook對話框。我想要我自己的。谷歌搜索後,我發現一些代碼,但它不工作。它不給予任何錯誤,但沒有發表任何事......如何在沒有打開對話框的情況下發布在Facebook牆上?

這裏我使用的是:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           @"Facebook developer Test Message",@"message", 
           @"Test it!",@"name",         
           nil]; 
Facebook *fb = [[Facebook alloc] init]; 
    [fb requestWithGraphPath:@"me/feed" // or use page ID instead of 'me' 
         andParams:params 
        andHttpMethod:@"POST" 
        andDelegate:self]; 

它不工作..

FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] 
    autorelease]; 
dialog.userMessagePrompt = @"Enter your message:"; 
dialog.attachment = [NSString 
    stringWithFormat:@"{\"name\":\"Facebook Connect for iPhone\",\"href\":\"http://developers.facebook.com/connect.phptab=iphone\",\"caption\":\"Caption\", \"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\",\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}"]; 

[dialog show]; 

這將打開一個對話框,問我鍵入消息,當我點擊它後將數據發佈到我的牆上。

我下面這個

http://forum.developers.facebook.net/viewtopic.php?id=79466

請告訴我在哪裏,我在做錯誤鏈接只好refferes。

感謝

+1

其中的委託方法被稱爲? – 2010-12-20 12:24:09

+2

另外,您可能想要接受一些答案。 – 2010-12-20 12:25:03

+1

你也可以考慮對幾個答案進行投票。 – Abizern 2010-12-20 12:37:29

回答

7

您好我認爲你可以做到這一點,就可以解決你的問題

NSString *[email protected]"Your String to post"; 

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            str,@"message", 
            @"Test it!",@"name",         
            nil]; 
Facebook *fb = [[Facebook alloc] init]; 
    [fb requestWithGraphPath:@"me/feed" // or use page ID instead of 'me' 
          andParams:params 
         andHttpMethod:@"POST" 
         andDelegate:self]; 
+0

是不是_exactly_相同Kapil的原始(除非你聲明瞭一個額外的,不必要的變量)。 – 2010-12-20 12:39:02

+0

是的,但這將適用於圖形API,所以我認爲它也可以在你的應用程序中工作。 – dks1725 2010-12-20 12:43:25

+0

嗨民歌,這是對的,我也是對的。我的錯誤是我沒有很好地理解fbgraph API – 2011-01-06 14:10:07

相關問題