本文整理匯總了C#中TweetSharp.TwitterService.PrepareEchoRequest方法的典型用法代碼示例。如果您正苦於以下問題:C# TwitterService.PrepareEchoRequest方法的具體用法?C# TwitterService.PrepareEchoRequest怎麽用?C# TwitterService.PrepareEchoRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TweetSharp.TwitterService
的用法示例。
在下文中一共展示了TwitterService.PrepareEchoRequest方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: UploadPhoto
///
/// Uploads the photo and sends a new Tweet
///
/// <param name="binaryImageData">The binary image data.
/// <param name="tweetMessage">The tweet message.
/// <param name="filename">The filename.
/// Return true, if the operation was succeded.
public string UploadPhoto(string imageFile, string tpkey, string usrtoken, string usrsecret, string contoken, string consecret)
{
TwitterService service = new TwitterService(contoken, consecret);
service.AuthenticateWith(usrtoken, usrsecret);
Hammock.RestRequest request = service.PrepareEchoRequest();
request.Path = "upload.xml";
request.AddFile("media", "uploadfile", imageFile, "image/jpeg");
request.AddField("key", tpkey);
Hammock.RestClient client = new Hammock.RestClient() { Authority = "http://api.twitpic.com", VersionPath = "2" };
Hammock.RestResponse response = client.Request(request);
if (response.StatusCode == HttpStatusCode.OK)
{
XDocument doc = XDocument.Parse(response.Content);
XElement image = doc.Element("image");
return image.Element("url").Value;
}
else
throw new Exception("Error occured while uploading image to TwitPic servers. Please try again later");
return "";
}