本文整理汇总了C#中LinqToTwitter.TwitterContext.TweetWithMedia方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterContext.TweetWithMedia方法的具体用法?C# TwitterContext.TweetWithMedia怎么用?C# TwitterContext.TweetWithMedia使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinqToTwitter.TwitterContext
的用法示例。
在下文中一共展示了TwitterContext.TweetWithMedia方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: tweetSnapShot
// take a snapshot on push gesture, and tweet it
public void tweetSnapShot(TwitterContext ctx)
{
// create a png bitmap encoder which knows how to save a .png file
BitmapEncoder encoder = new PngBitmapEncoder();
// create frame from the writable bitmap and add to encoder
encoder.Frames.Add(BitmapFrame.Create(this.colorBitmap));
string time = System.DateTime.Now.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat);
string saveDirectory = @"..\..\Snapshots";
string filename = "KinectSnapshot-" + time + ".png";
string path = System.IO.Path.Combine(saveDirectory, filename);
// write the new file to disk
try
{
using (FileStream fs = new FileStream(path, FileMode.Create))
{
encoder.Save(fs);
}
}
catch (IOException)
{
Console.WriteLine("Saving Snapshot Failed");
}
var mediaItems =
new List<Media>
{
new Media
{
Data = Utilities.GetFileBytes(path),
FileName = filename,
ContentType = MediaContentType.Png
}
};
// tweeting with media takes the picture file and the status message
var tweet = ctx.TweetWithMedia("Tweeting with media! #KineXionZ",false,mediaItems);
}
示例2: TweetWithMediaDemo
static void TweetWithMediaDemo(TwitterContext twitterCtx)
{
string status = "Testing TweetWithMedia #Linq2Twitter £ " + DateTime.Now.ToString(CultureInfo.InvariantCulture);
const bool PossiblySensitive = false;
const decimal Latitude = StatusExtensions.NoCoordinate; //37.78215m;
const decimal Longitude = StatusExtensions.NoCoordinate; // -122.40060m;
const bool DisplayCoordinates = false;
const string ReplaceThisWithYourImageLocation = @"..\..\images\200xColor_2.png";
var mediaItems =
new List<Media>
{
new Media
{
Data = Utilities.GetFileBytes(ReplaceThisWithYourImageLocation),
FileName = "200xColor_2.png",
ContentType = MediaContentType.Png
}
};
Status tweet = twitterCtx.TweetWithMedia(
status, PossiblySensitive, Latitude, Longitude,
null, DisplayCoordinates, mediaItems, null);
Console.WriteLine("Media item sent - Tweet Text: " + tweet.Text);
}