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


C# TwitterContext.UpdateStatus方法代码示例

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


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

示例1: PostToTwitter

        public ActionResult PostToTwitter(string url, string text)
        {
            if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(text))
                return Json(new { Success = false, Message = "You must enter some text to tweet" });

            IOAuthCredentials credentials = new SessionStateCredentials();

            credentials.ConsumerKey = _config.TwitterConsumerKey;
            credentials.ConsumerSecret = _config.TwitterConsumerSecret;
            credentials.AccessToken = _config.TwitterAccessTokenSecret;
            credentials.OAuthToken = _config.TwitterAccessToken;

            MvcAuthorizer auth = new MvcAuthorizer { Credentials = credentials };

            TwitterContext twitter = new TwitterContext(auth);

            try
            {
                twitter.UpdateStatus(text + " " + url);

                return Json(new { Success = true });
            }
            catch (Exception e)
            {
                return Json(new { Success = false, Message = e.Message });
            }
        }
开发者ID:markashleybell,项目名称:eclectica.co.uk,代码行数:27,代码来源:EntryController.cs

示例2: UpdateStatus

 public static void UpdateStatus(string tweet, IOAuthCredentials credentials) {
     var singleUserAuthorizer = new SingleUserAuthorizer {
         Credentials = credentials
     };
     var twitterCtx = new TwitterContext(singleUserAuthorizer);
     twitterCtx.UpdateStatus(tweet);
 }
开发者ID:slieser,项目名称:sandbox,代码行数:7,代码来源:Linq2TwitterSpikes.cs

示例3: BindDemo

        private void BindDemo()
        {
            ITwitterAuthorizer autentikasi = GetInformasiKredensial();

            var TwitterDataContext = new TwitterContext(autentikasi);

            var status = TwitterDataContext.UpdateStatus("Skuad jadi latihan teu?");
        }
开发者ID:go2ismail,项目名称:JurusTwitterAPISourceCode,代码行数:8,代码来源:Default.aspx.cs

示例4: Tweet

 public string Tweet(ITwitterAuthorizer auth, string status)
 {
   using (var twitterCtx = new TwitterContext(auth))
   {
     var tweet = twitterCtx.UpdateStatus(status);
     
     return tweet.StatusID;
   }
 } 
开发者ID:Double222,项目名称:Samurai,代码行数:9,代码来源:TwitterClient.cs

示例5: Tweet

        private bool Tweet(string action, string subject, string url, string hashTags)
        {
            var message = string.Format("{0} {1}: {2} {3}", action, subject, url, hashTags);

            using (var twitterContext = new TwitterContext(this.authorizer))
            {
                var status = twitterContext.UpdateStatus(message, true);

                return status != null;
            }
        }
开发者ID:Dakuan,项目名称:RiftData,代码行数:11,代码来源:TwitterService.cs

示例6: HandleOAuthSideEffectReadOnlyDemo

        /// <summary>
        /// shows what happens when performing a side-effect when ReadOnly is turned on
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void HandleOAuthSideEffectReadOnlyDemo(TwitterContext twitterCtx)
        {
            if (twitterCtx.AuthorizedClient.IsAuthorized)
            {
                var status = twitterCtx.UpdateStatus("I used LINQ to Twitter with OAuth: " + DateTime.Now.ToString());

                Console.WriteLine(
                    "Friend: {0}\nTweet: {1}\n",
                    status.User.Name,
                    status.Text);
            }
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:16,代码来源:OAuthDemos.cs

示例7: postUpdateButton_Click

    protected void postUpdateButton_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        twitterCtx = new TwitterContext(auth);
        twitterCtx.UpdateStatus(updateBox.Text);
        updateBox.Text = string.Empty;
        successLabel.Visible = true;
    }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:12,代码来源:PostOnly.aspx.cs

示例8: PostTweet

 public JsonResult PostTweet(string tweet)
 {
     Authorize();
     twitterCtx = new TwitterContext(auth);
     try
     {
         twitterCtx.UpdateStatus(tweet);
         return Json(new { success = true });
     }
     catch (Exception ex)
     {
         return Json(new { success = false });
     }
 }
开发者ID:Choulla-Naresh8264,项目名称:angularjs-services,代码行数:14,代码来源:HomeController.cs

示例9: SendAnswer

        /// <summary>
        /// Send an answer through twitter with the related question
        /// </summary>
        /// <param name="question"></param>
        /// <param name="answer">The answer given by expert, answer.Content + reference can't be longer then 140 characters</param>
        public void SendAnswer(Question question, Answer answer)
        {
            var reference = question.Source.Source.Value;
            var postId = question.Source.PostId;

            var status = reference + " " + answer.Content;

            validation.StringCheck(postId);
            validation.TweetLengthCheck(status);

            using (TwitterContext twitterCtx = new TwitterContext(PinAutharizedUser))
            {
                var tweet = twitterCtx.UpdateStatus(status, postId);                
            }
        }        
开发者ID:Teunozz,项目名称:nl.fhict.intellicloud.backend,代码行数:20,代码来源:TwitterSendAnswerPlugin.cs

示例10: Main

 static void Main(string[] args)
 {
     var auth = new SingleUserAuthorizer {
         Credentials = new SingleUserInMemoryCredentials {
             ConsumerKey = args[0],
             ConsumerSecret = args[1],
             TwitterAccessToken = args[2],
             TwitterAccessTokenSecret = args[3]
         }
     };
     auth.Authorize();
     if (!auth.IsAuthorized)
         throw new AuthenticationException();
     var twitterCtx = new TwitterContext(auth);
     twitterCtx.UpdateStatus(args[4]);
 }
开发者ID:ErikWitkowski,项目名称:Support,代码行数:16,代码来源:Program.cs

示例11: tweet

        public static void tweet(String what)
        {
            XmlNodeList nodes = prepareXML();

            var auth = new SingleUserAuthorizer
            {
                Credentials = new InMemoryCredentials
                {
                    ConsumerKey = nodes.Item(0).InnerText,
                    ConsumerSecret = nodes.Item(1).InnerText,
                    OAuthToken = nodes.Item(2).InnerText,
                    AccessToken = nodes.Item(3).InnerText,
                }
            };

            var service = new TwitterContext(auth);
            var tweet = service.UpdateStatus(what.Trim());
        }
开发者ID:MilosSimic,项目名称:snakeRoot,代码行数:18,代码来源:Class1.cs

示例12: TweetButton_Click

        private void TweetButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TweetTextBox.Text))
            {
                MessageBox.Show("Please enter text to tweet.");
            }

            ITwitterAuthorizer auth = SharedState.Authorizer;

            if (auth == null || !auth.IsAuthorized)
            {
                NavigationService.Navigate(new Uri("/OAuth.xaml", UriKind.Relative));
            }
            else
            {
                var twitterCtx = new TwitterContext(auth);

                twitterCtx.UpdateStatus(TweetTextBox.Text,
                    updateResp => Dispatcher.BeginInvoke(() =>
                    {
                        switch (updateResp.Status)
                        {
                            case TwitterErrorStatus.Success:
                                Status tweet = updateResp.State;
                                User user = tweet.User;
                                UserIdentifier id = user.Identifier;
                                MessageBox.Show(
                                    "User: " + id.ScreenName +
                                    ", Posted Status: " + tweet.Text,
                                    "Update Successfully Posted.",
                                    MessageBoxButton.OK);
                                break;
                            case TwitterErrorStatus.TwitterApiError:
                            case TwitterErrorStatus.RequestProcessingException:
                                MessageBox.Show(
                                    updateResp.Exception.ToString(),
                                    updateResp.Message,
                                    MessageBoxButton.OK);
                                break;
                        }
                    }));
            }
        }
开发者ID:CheyPMK,项目名称:linqtotwitter,代码行数:43,代码来源:StatusUpdate.xaml.cs

示例13: HandleSideEffectExceptionDemo

        /// <summary>
        /// shows how to handle a TwitterQueryException with a side-effect
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void HandleSideEffectExceptionDemo(TwitterContext twitterCtx)
        {
            // force the error by supplying bad credentials
            twitterCtx.AuthorizedClient = new UsernamePasswordAuthorization
            {
                UserName = "BadUserName",
                Password = "BadPassword",
            };

            try
            {
                var status = twitterCtx.UpdateStatus("Test from LINQ to Twitter - 5/2/09");
            }
            catch (TwitterQueryException tqe)
            {
                // log it to the console
                Console.WriteLine(
                    "\nHTTP Error Code: {0}\nError: {1}\nRequest: {2}\n",
                    tqe.HttpError,
                    tqe.Response.Error,
                    tqe.Response.Request);
            }
        }
开发者ID:giggio,项目名称:tweetercloud,代码行数:27,代码来源:ErrorHandlingDemos.cs

示例14: UpdateStatusDemo

        /// <summary>
        /// shows how to update a status
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void UpdateStatusDemo(TwitterContext twitterCtx)
        {
            var status =
                " Testing LINQ to Twitter update status on " +
                DateTime.Now.ToString() + " #linqtotwitter "
                //+
                //@"`[email protected]#$%^&*()_-+=.~,:;'?/|\[] éü\u00C7"
                ;

            Console.WriteLine("\nStatus being sent: \n\n\"{0}\"", status);
            Console.WriteLine("\nPress any key to post tweet...\n");
            Console.ReadKey();

            var tweet = twitterCtx.UpdateStatus(status);

            Console.WriteLine(
                "Status returned: " +
                "(" + tweet.StatusID + ")" +
                "[" + tweet.User.ID + "]" +
                tweet.User.Name + ", " +
                tweet.Text + ", " +
                tweet.CreatedAt + "\n");
        }
开发者ID:CheyPMK,项目名称:linqtotwitter,代码行数:27,代码来源:StatusDemos.cs

示例15: UpdateStatusWithCallbackDemo

        /// <summary>
        /// shows how to asynchronously update a status
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void UpdateStatusWithCallbackDemo(TwitterContext twitterCtx)
        {
            //Thread.CurrentThread.CurrentCulture = new CultureInfo("nn-NO");
            //Thread.CurrentThread.CurrentUICulture = new CultureInfo("nn-NO");
            var status =
                " Testing LINQ to Twitter update status on " +
                DateTime.Now.ToString() + " #linqtotwitter "
                //+ @"`[email protected]#$%^&*()_-+=.~,:;'?/|\[] éü\u00C7"
                ;

            Console.WriteLine("\nStatus being sent: \n\n\"{0}\"", status);
            Console.WriteLine("\nPress any key to post tweet...\n");
            Console.ReadKey();

            twitterCtx.UpdateStatus(status,
                response =>
                {
                    if (response.Status == TwitterErrorStatus.Success)
                    {
                        Status tweet = response.State;

                        Console.WriteLine(
                            "Status returned: " +
                            "(" + tweet.StatusID + ")" +
                            "[" + tweet.User.ID + "]" +
                            tweet.User.Name + ", " +
                            tweet.Text + ", " +
                            tweet.CreatedAt + "\n");
                    }
                    else
                    {
                        Console.WriteLine(response.Exception.ToString());
                    }
                });
        }
开发者ID:CheyPMK,项目名称:linqtotwitter,代码行数:39,代码来源:StatusDemos.cs


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