当前位置: 首页>>代码示例>>C#>>正文


C# TwitterContext.TweetAsync方法代码示例

本文整理汇总了C#中LinqToTwitter.TwitterContext.TweetAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterContext.TweetAsync方法的具体用法?C# TwitterContext.TweetAsync怎么用?C# TwitterContext.TweetAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinqToTwitter.TwitterContext的用法示例。


在下文中一共展示了TwitterContext.TweetAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendTweetWithSinglePicture

        static async void SendTweetWithSinglePicture()
        {
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = "your consumer key",
                    ConsumerSecret = "your consumer secret",
                    AccessToken = "your access token",
                    AccessTokenSecret = "your access token secret"
                }
            };

            var context = new TwitterContext(auth);

            var uploadedMedia = await context.UploadMediaAsync(File.ReadAllBytes(@"c:\path\to\image.jpg"));
            var mediaIds = new List<ulong> { uploadedMedia.MediaID };

            await context.TweetAsync(
                "Hello World! I am testing @dougvdotcom's #LinqToTwitter demo, at " +
                "https://www.dougv.com/2015/08/posting-twitter-status-updates-tweets-with-linqtotwitter-and-net-part-3-media-tweets",
                mediaIds
            );
        }
开发者ID:dougvdotcom,项目名称:linqtotwitter_demo,代码行数:24,代码来源:Program.cs

示例2: PostTwitter

        public static async void PostTwitter()
        {
            string pl;

            //var auth = AuthorizeTwitter();

            var auth = AuthorizeTwitterWithToken();



            var ctx = new TwitterContext(auth);

            //var new Media
            //    {
            //        Data = Utilities.GetFileBytes(replaceThisWithYourImageLocation),
            //        FileName = "200xColor_2.png",
            //        ContentType = MediaContentType.Png
            //    };

            //await ctx.TweetWithMediaAsync("Testing from Application. Posting Image", false, ReadImageFile(Path.GetFullPath("image.png")));

            await ctx.TweetAsync("Testing from Application. Second Tweet!");
            //var twitterCtx = new TwitterContext(auth);

            await TwitterParameters(auth);
        }
开发者ID:riskypathak,项目名称:Poster,代码行数:26,代码来源:Program.cs

示例3: TweetButton_Click

        async void TweetButton_Click(object sender, RoutedEventArgs e)
        {
            var twitterCtx = new TwitterContext(SharedState.Authorizer);

            Status tweet = await twitterCtx.TweetAsync(TweetTextBox.Text);

            await new MessageDialog(tweet.Text, "Tweet Sent").ShowAsync();
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:8,代码来源:TweetDemo.xaml.cs

示例4: SendTweet

        public static async void SendTweet(MvcAuthorizer auth, string message)
        {
            
            var ctx = new TwitterContext(auth);
            var context = new TwitterContext(auth);

            await context.TweetAsync(
                message
            );
        }
开发者ID:unionthugface,项目名称:wehack,代码行数:10,代码来源:TwitterService.cs

示例5: ReTweet

        public static async void ReTweet(MvcAuthorizer auth, int ID)
        {

            var ctx = new TwitterContext(auth);
            var context = new TwitterContext(auth);

            await context.TweetAsync(
                ID.ToString()
            );
        }
开发者ID:unionthugface,项目名称:wehack,代码行数:10,代码来源:TwitterService.cs

示例6: AsyncMain

        static async Task AsyncMain()
        {
            // Get repositories
            string[] repos = ConfigurationManager.AppSettings["Repositories"]
                .Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => x.Trim())
                .ToArray();

            // Get excluded users
            string[] excludedUsers = ConfigurationManager.AppSettings["ExcludedUsers"]
                .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => x.Trim())
                .ToArray();

            // Authorize to GitHub
            string token = ConfigurationManager.AppSettings["GitHubToken"];
            GitHubClient github = new GitHubClient(new ProductHeaderValue("IssueTweeter"))
            {
                Credentials = new Credentials(token)
            };

            // Get issues for each repo
            DateTimeOffset since = DateTimeOffset.UtcNow.AddHours(-1);
            List<Task<List<KeyValuePair<string, string>>>> issuesTasks = repos.Select(x => GetIssues(github, x, since, excludedUsers)).ToList();
            await Task.WhenAll(issuesTasks);

            // Authorize to Twitter
            SingleUserAuthorizer twitterAuth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"],
                    AccessToken = ConfigurationManager.AppSettings["TwitterAccessToken"],
                    AccessTokenSecret = ConfigurationManager.AppSettings["TwitterAccessTokenSecret"]
                }
            };
            TwitterContext twitterContext = new TwitterContext(twitterAuth);

            // Get recent tweets
            string twitterUser = ConfigurationManager.AppSettings["TwitterUser"];
            List<Status> timeline = await twitterContext.Status
                .Where(x => x.Type == StatusType.User && x.ScreenName == twitterUser && x.Count == 200)
                .ToListAsync();

            // Aggregate and eliminate issues already tweeted
            List<string> tweets = issuesTasks
                .SelectMany(x => x.Result.Where(i => !timeline.Any(t => t.Text.Contains(i.Key))).Select(i => i.Value))
                .ToList();

            // Send tweets
            List<Task<Status>> tweetTasks = tweets.Select(x => twitterContext.TweetAsync(x)).ToList();
            await Task.WhenAll(tweetTasks);
        }
开发者ID:daveaglick,项目名称:IssueTweeter,代码行数:54,代码来源:Program.cs

示例7: PostUpdateButton_Click

        protected async void PostUpdateButton_Click(object sender, EventArgs e)
        {
            var auth = new AspNetAuthorizer
            {
                CredentialStore = new SessionStateCredentialStore(),
                GoToTwitterAuthorization = twitterUrl => { }
            };

            var ctx = new TwitterContext(auth);

            await ctx.TweetAsync(UpdateTextBox.Text);

            SuccessLabel.Visible = true;
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:14,代码来源:TweetDemo.aspx.cs

示例8: TweetAsync

		public async Task<bool> TweetAsync(string content)
		{
			var tweetContent = CheckContent(content);

			try
			{
				using (var context = new TwitterContext(_selfAuthorizer))
				{
					await context.TweetAsync(content);
					return true;
				}
			}
			catch (TwitterQueryException ex) when (ex.StatusCode == HttpStatusCode.Forbidden) // In case of duplicate
			{
				return false;
			}
		}
开发者ID:emoacht,项目名称:CSharpPlay,代码行数:17,代码来源:TweetWorker.cs

示例9: nouveauTweetBouton_Click

        private void nouveauTweetBouton_Click(object sender, EventArgs e)
        {
            var twitterContext = new TwitterContext(authorizer);

            nouveauTweetFenetre nt = new nouveauTweetFenetre();

            if (nt.ShowDialog() == DialogResult.OK)
            {

                if (nt.Tweet.Length > 0)
                {
                    twitterContext.TweetAsync(nt.Tweet);
                    MessageBox.Show("Le tweet est publié");
                }

                recupererTweets();
            }
        }
开发者ID:MichaelMondou,项目名称:Cours,代码行数:18,代码来源:FenetrePrincipale.cs

示例10: Main

        static void Main(string[] args)
        {
            Task.Run(async () =>
            {

                AppSettingsReader cfgReader = new AppSettingsReader();

                string _UseProxy = cfgReader.GetValue("UseProxy", typeof(string)).ToString();

                var auth = new SingleUserAuthorizer
                {
                    CredentialStore = new SingleUserInMemoryCredentialStore
                    {
                        ConsumerKey = cfgReader.GetValue("ConsumerKey", typeof(string)).ToString(),
                        ConsumerSecret = cfgReader.GetValue("ConsumerSecret", typeof(string)).ToString(),
                        AccessToken = cfgReader.GetValue("AccessToken", typeof(string)).ToString(),
                        AccessTokenSecret = cfgReader.GetValue("AccessSecret", typeof(string)).ToString()
                    }
                };

                if (_UseProxy.Equals("1"))
                {
                    auth.Proxy = new WebProxy(cfgReader.GetValue("ProxyAddress", typeof(string)).ToString());
                    auth.Proxy.Credentials = new NetworkCredential(
                        cfgReader.GetValue("ProxyUser", typeof(string)).ToString(),
                        cfgReader.GetValue("ProxyPass", typeof(string)).ToString());
                }

                var twitterContext = new TwitterContext(auth);

                string _teste = "Tweet sent via LinqToTwitter";

                var tweet = await twitterContext.TweetAsync(_teste);

                if (tweet != null)
                {
                    Console.WriteLine("Status: {0}", tweet.StatusID.ToString());
                }

            }).Wait();

            Console.ReadLine();
        }
开发者ID:thealchemistbr,项目名称:Poster,代码行数:43,代码来源:MainPoster.cs

示例11: TweetAsync

        public async Task<ActionResult> TweetAsync(SendTweetViewModel tweet)
        {
            var auth = new MvcAuthorizer
            {
                CredentialStore = new SessionStateCredentialStore()
            };

            var ctx = new TwitterContext(auth);

            Status responseTweet = await ctx.TweetAsync(tweet.Text);

            var responseTweetVM = new SendTweetViewModel
            {
                Text = "Testing async LINQ to Twitter in MVC - " + DateTime.Now.ToString(),
                Response = "Tweet successful! Response from Twitter: " + responseTweet.Text
            };

            return View(responseTweetVM);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:19,代码来源:StatusDemosController.cs

示例12: TweetButton_Click

        async void TweetButton_Click(object sender, RoutedEventArgs e)
        {
            IAuthorizer auth = SharedState.Authorizer;

            var twitterCtx = new TwitterContext(auth);

            decimal latitude = 37.78215m;
            decimal longitude = -122.40060m;

            Status tweet = await twitterCtx.TweetAsync(TweetTextBox.Text, latitude, longitude);

            MessageBox.Show(
                "User: " + tweet.User.ScreenNameResponse +
                ", Posted Status: " + tweet.Text,
                "Update Successfully Posted.",
                MessageBoxButton.OK);

            TweetTextBox.Text = "Windows Phone Test, " + DateTime.Now.ToString() + " #linq2twitter";
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:19,代码来源:TweetDemo.xaml.cs

示例13: SendTweet

        static async void SendTweet()
        {
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = "your consumer key",
                    ConsumerSecret = "your consumer secret",
                    AccessToken = "your access token",
                    AccessTokenSecret = "your access token secret"
                }
            };

            var context = new TwitterContext(auth);

            await context.TweetAsync(
                "Hello World! I am testing @dougvdotcom's #LinqToTwitter demo, at " +
                "https://www.dougv.com/2015/08/posting-status-updates-to-twitter-via-linqtotwitter-part-2-plain-text-tweets"
            );
        }
开发者ID:dougvdotcom,项目名称:linqtotwitter_demo,代码行数:20,代码来源:Program.cs

示例14: TweetButton_Click

        private async void TweetButton_Click(object sender, RoutedEventArgs e)
        {
            var authorizer = new UniversalAuthorizer
            {
                CredentialStore = new InMemoryCredentialStore
                {
                    ConsumerKey = "",
                    ConsumerSecret = ""
                }
            };

            await authorizer.AuthorizeAsync();
            var ctx = new TwitterContext(authorizer);

            string userInput = tweetText.Text;
            Status tweet = await ctx.TweetAsync(userInput);

            ResponseTextBlock.Text = tweet.Text;

            await new MessageDialog("You Tweeted: " + tweet.Text, "Success!").ShowAsync();
        }
开发者ID:yaremado,项目名称:LinqToTwitter,代码行数:21,代码来源:TweetPage.xaml.cs

示例15: PostTweet

        public async Task<ActionResult> PostTweet(string tweetText = "")
        {
            MvcAuthorizer auth = new MvcAuthorizer
            {
                CredentialStore = new SessionStateCredentialStore()
            };

            // do OAuth if the token is null
            if (auth.CredentialStore.OAuthToken == null)
            {
                return RedirectToAction("BeginAsync", "OAuth", new { returnUrl = Request.Url });
            }

            Status postedTweet;
            ulong postedTweetStatusId = 0;
            if (!string.IsNullOrEmpty(tweetText))
            {
                var twitterCtx = new TwitterContext(auth);

                postedTweet = await twitterCtx.TweetAsync(tweetText);

                postedTweetStatusId = postedTweet.StatusID;
            }
            else
            {
                postedTweet = null;
            }

            var viewModel = new PostTweetViewModel()
            {
                TweetText = tweetText,
                PostedTweet = postedTweet,
                PostedTweetStatusId = postedTweetStatusId
            };

            return View(viewModel);
        }
开发者ID:martinkearn,项目名称:TweetFromOffice,代码行数:37,代码来源:HomeController.cs


注:本文中的LinqToTwitter.TwitterContext.TweetAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。