2012-06-18 59 views
1

我已經搜索了很多關於在Facebook上發佈屏幕截圖的論壇和主題。我找到了在CCDirector中添加的功能,它創建了屏幕截圖。我也看到了在Facebook或牆上發佈facebook截圖的方法。但是這對我沒有用。通過Cocos2d發佈GameOver到FaceBook的屏幕截圖

UIImage *tempImage = [[CCDirector sharedDirector] screenshotUIImage]; 

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            tempImage,@"message", 
            nil]; 

[facebook requestWithGraphPath:@"me/photos" 
         andParams:params 
        andHttpMethod:@"POST" 
         andDelegate:self]; 

screenshotUIImage是使屏幕截圖的功能,它工作正常。 requestWithGraphPath對我沒有任何幫助。我在「tempImage」,「source」,「tempImage,@」image「等參數中使用了不同的關鍵字,但沒有任何反應。

但是,在牆上發佈文字,就像高分與預定義的圖像鏈接工作正常。

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           imageSrc, @"picture", 
           serverLink, @"link", 
           postName, @"name", 
           customMessage, @"caption", 
           nil]; 

// Post on Facebook. 
[_facebook dialog:@"feed" andParams:params andDelegate:self]; 

任何人可以指導我如何做圖片發佈?

回答

1

在您的參數,可以你可以嘗試指定一個UIImage的關鍵「圖片報」:

UIImage *tempImage = [[CCDirector sharedDirector] screenshotUIImage]; 

NSMutableDictionary *params = [NSMutableDictionary dictionary];  
[params setObject:myCaption forKey:@"caption"]; 
[params setObject:myMessage forKey:@"message"]; 
... 
// UIImage object goes here 
[params setObject:tempImage forKey:@"picture"]; 

[facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self]; 
+0

感謝您的幫助,但它仍然沒有爲我工作。在共享按鈕上切換到Facebook權限頁面。在Facebook頁面上按下okey按鈕後,它切換回遊戲,但沒有任何反應。如果我使用這一行'[_facebook dialog:@「feed」andParams:params andDelegate:self]發佈簡單文本;''它會詢問權限,當它切換回遊戲時,會在遊戲屏幕上顯示Facebook登錄對話框。登錄後,它顯示文本與共享按鈕共享,它的工作完美。使用requestWithGraphPath進行圖片共享時沒有對話。難道我做錯了什麼? –

+0

你是否設法讓它工作?也許你可以嘗試通過Sharekit發佈圖片。實際上,請查看:https://github.com/ShareKit/ShareKit/blob/master/Classes/ShareKit/Sharers/Services/Facebook/SHKFacebook.m#L247,瞭解他們如何通過FB Graph API實現UIImage發佈。顯然,它是以相似的方式完成的。 –

+0

謝謝,我會試着這樣做。希望這一次它的工作。 –