2013-03-17 27 views
4

這裏的任何人都試過使用TweetSharp發送圖片嗎?TweetSharp SendTweetWithMediaOptions示例

我試過如下:

Dictionary<string, Stream> imageDict = new Dictionary<string, Stream>(); 
imageDict.Add(imagePath, imageStream); 
// I'm getting an error with the line below. 
// It's saying I have some invalid arguments. :(
status = service.SendTweet(new SendTweetWithMediaOptions() { Status = readerMsg.Message, Images = imageDict }); 

但最後一行是給我,沒有幫助的原因,無效參數錯誤。

我試着看着他們的GitHub頁面,但該示例僅說明了如何發佈簡單的文本消息。

+0

請參閱本拉請求的第一部分.. HTTPS:/ /github.com/danielcrenna/tweetsharp/pull/65/files 調用'SendTweetWithMedia'而不是'SendTweet'可能是問題所在。另外,字典中的關鍵字似乎並不是圖像路徑(無論如何,您都會給它一個「Stream」)示例將「測試」傳遞給它。 --HTH – Madushan 2013-03-17 10:30:41

+0

工作正常!感謝您指出SendTweet錯誤。創建一個答案,我會接受它。 :) – Ron 2013-03-17 10:41:36

+0

張貼..見下文。 - 謝謝 - – Madushan 2013-03-18 06:17:20

回答

5

見本拉入請求的第一部分:TweetSharp Github

主叫SendTweetWithMedia代替SendTweet可能是這種情況。

此外,字典中的關鍵字似乎並不是圖像路徑(無論如何你都要給它一個Stream),例子會通過「測試」。

--HTH 玩得開心

1

service.SendTweet()接受SendTweetOptions類型的參數,如果你想發表圖片您可以使用

service.SendTweetWithMedia(new SendTweetWithMediaOptions 
{ 
    Status = "message", 
    Images = dictionary 
} 
);