當前位置: 首頁>>代碼示例>>C#>>正文


C# TwitterService.SendTweet方法代碼示例

本文整理匯總了C#中TweetSharp.TwitterService.SendTweet方法的典型用法代碼示例。如果您正苦於以下問題:C# TwitterService.SendTweet方法的具體用法?C# TwitterService.SendTweet怎麽用?C# TwitterService.SendTweet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TweetSharp.TwitterService的用法示例。


在下文中一共展示了TwitterService.SendTweet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SendTextMessage

        private static List<TwitterStatus> SendTextMessage(TwitterService service, MessageEntity message)
        {
            List<TwitterStatus> statuses = new List<TwitterStatus>();

            String hashTag = String.Format("{0}{1}", "#LiveSkypeChat", Environment.NewLine); //TODO: module - defining current top hashtag

            List<string> splittedTwitterMessage = SplitMessage(message.TwitterMessage, hashTag);

            int messgaeIndex = 0;

            foreach (string messagePart in splittedTwitterMessage)
            {
                String twitterMessage = String.Empty;
                messgaeIndex++;

                if (splittedTwitterMessage.Count > 1)
                {
                    String counter = String.Format("{0}/{1}{2}", messgaeIndex, splittedTwitterMessage.Count, Environment.NewLine);
                    twitterMessage = String.Format("{0}{1}{2}: {3}", hashTag, counter, message.TwitterNick, messagePart);
                }
                else
                {
                    twitterMessage = String.Format("{0}{1}: {2}", hashTag, message.TwitterNick, messagePart);
                }

                TwitterStatus status = service.SendTweet(new SendTweetOptions { Status = twitterMessage });
                statuses.Add(status);
            }

            return statuses;
        }
開發者ID:skpSlave,項目名稱:skpSlaveBot,代碼行數:31,代碼來源:TwitterTools.cs

示例2: ApplicationBarIconButton_Click

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            if (img_bool == true && twit_pic == "")
            {
                MessageBox.Show("Image upload in progress. please wait.", "Sorry", MessageBoxButton.OK);
                return;
            }

            if (WatermarkTB.Text == emptystr)
            {
                MessageBox.Show("Please input your mind :)", "Sorry", MessageBoxButton.OK);
                return;
            }

            TwitterService service = new TwitterService("g8F2KdKH40gGp9BXemw13Q", "OyFRFsI05agcJtURtLv8lpYbYRwZAIL5gr5xQNPW0Q");
            service.AuthenticateWith((string)settings["twitter_token"], (string)settings["twitter_tokensecret"]);
            string tweet = WatermarkTB.Text;
            if (img_bool == true)
                tweet += " " + twit_pic;

            service.SendTweet(tweet,
                (tweets, response) =>
                {

                });
            MessageBox.Show("Share successfully.", "Thanks", MessageBoxButton.OK);
            this.NavigationService.GoBack();
        }
開發者ID:vapps,項目名稱:HDStream,代碼行數:28,代碼來源:TwitterWrite.xaml.cs

示例3: CanUpdateStatus

        public void CanUpdateStatus()
        {
            var service = new TwitterService(consumerKey, consumerSecret);
            service.AuthenticateWith(accessToken, accessTokenSecret);

            var tweet = service.SendTweet("@SocSnapTest " + DateTime.Now.ToLongTimeString() + " @SocSnapTest");
            Console.WriteLine(tweet.Text);
        }
開發者ID:mikehadlow,項目名稱:socsnap,代碼行數:8,代碼來源:TweetSharpSpike.cs

示例4: NotifyUserOnTwitter

        private void NotifyUserOnTwitter(ChatMessage message, User user, TwitterUser u)
        {
            TweetSharp.TwitterService svc = new TwitterService(GetClientInfo());
            svc.AuthenticateWith(ConfigurationManager.AppSettings["User.Token"],
                ConfigurationManager.AppSettings["User.TokenSecret"]);
            svc.SendTweet(String.Format(_tweetFormat,
                u.ScreenName,
                String.IsNullOrEmpty(user.TwitterUserName) ? user.JabbrUserName : user.TwitterUserName, message.Room));

        }
開發者ID:sethwebster,項目名稱:Jabbot.TwitterNotifierSprocket,代碼行數:10,代碼來源:TwitterNotifierSprocket.cs

示例5: SendTweet

        public TwitterStatus SendTweet(string message)
        {
            TwitterService service = new TwitterService(ConsumerKey, ConsumerSecret);
            service.AuthenticateWith(Token, Secret);

            return service.SendTweet(new SendTweetOptions()
                {
                    Status = message
                });
            //return null;
        }
開發者ID:sreverdy,項目名稱:JobPF,代碼行數:11,代碼來源:TweetManager.cs

示例6: Tweet

        public static void Tweet(string message)
        {
            string consumerKey = ConfigurationManager.AppSettings["twiiterConsumerKey"];
            string consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"];
            string accessToken = ConfigurationManager.AppSettings["twitterAccessToken"];
            string accessTokenSecret = ConfigurationManager.AppSettings["twitterAccessTokenSecret"];

            var service = new TwitterService(consumerKey, consumerSecret);
            service.AuthenticateWith(accessToken, accessTokenSecret);
            service.SendTweet(new SendTweetOptions { Status = message});
        }
開發者ID:richard-kong,項目名稱:sabnzbd-kdrama-processing,代碼行數:11,代碼來源:Program.cs

示例7: SendTweet

        public static void SendTweet(   string sMessage, 
                                        string consumerKey, 
                                        string consumerSecret, 
                                        string token, 
                                        string tokenSecret)
        {
            TwitterService service = new TwitterService(consumerKey, consumerSecret);
            service.AuthenticateWith(token, tokenSecret);

            TwitterStatus status = service.SendTweet(sMessage);
        }
開發者ID:alpascual,項目名稱:Unfollower,代碼行數:11,代碼來源:TwitterUtils.cs

示例8: SendTweet

 public static bool SendTweet(TwitterService service, string status, long inReplyToStatusId)
 {
     var sendoptions = new SendTweetOptions ();
     sendoptions.Status = status;
     sendoptions.InReplyToStatusId = inReplyToStatusId;
     var response = service.SendTweet (sendoptions);
     if (response == null) {
         Console.WriteLine ("ERROR SENDING TWEET! Possible duplicate!");
         return false;
     }
     return true;
 }
開發者ID:MadeInSpengergasse,項目名稱:ReplyBot,代碼行數:12,代碼來源:TwitterHelper.cs

示例9: SendTweet

        public void SendTweet(string message)
        {
            if (string.IsNullOrEmpty(message))
                throw new ArgumentNullException("message");

            if (message.Length > TweetLength)
                throw new ArgumentException("Message is too long. MaxLength is 120", "message");

            var service = new TwitterService(ConsumerKey, ConsumerSecret);
            service.AuthenticateWith(AccessToken, AccessTokenSecret);
            service.SendTweet(new SendTweetOptions {
                Status = message
            });
        }
開發者ID:geekhubdk,項目名稱:geekhub,代碼行數:14,代碼來源:LiveTwitterAdapter.cs

示例10: TryPerformTwitterPost

        /// <summary>
        /// Workerthread: Performs the TwitterFeed Post
        /// </summary>
        /// <param name="BasicProgramData"></param>
        void TryPerformTwitterPost()
        {
            if (CalibrationSettings.Default.EnableTwitterFeed == true)
            {
                string _consumerKey = ConfigurationManager.AppSettings["ConsumerKey"];
                string _consumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"];
                string _accessToken = ConfigurationManager.AppSettings["AccessToken"];
                string _accessTokenSecret = ConfigurationManager.AppSettings["AccessTokenSecret"];

                var service = new TwitterService(_consumerKey, _consumerSecret);
                service.AuthenticateWith(_accessToken, _accessTokenSecret);
                TwitterStatus status = service.SendTweet(twitterMessage);
            }
        }
開發者ID:antonesterhuyse,項目名稱:GrucoxScrumView,代碼行數:18,代碼來源:DataComms.cs

示例11: SendTweet

        protected void SendTweet(object tweetMessage)
        {

            var tweet = (string)tweetMessage;
            try
            {
                var twitterApp = new TwitterService(settings.ConsumerKey, settings.ConsumerSecret);
                twitterApp.AuthenticateWith(settings.Token, settings.TokenSecret);
                twitterApp.SendTweet(new SendTweetOptions {Status = tweet});
                logger.Trace("'{0}' was tweeted",tweet);
            }
            catch (Exception ex)
            {
                logger.Warn("The tweet '{0}' failed with the exception: {1}", tweet,ex.Message);
            }
        }
開發者ID:Jc54,項目名稱:PlayMe,代碼行數:16,代碼來源:TwitterBroadcaster.cs

示例12: UnsafeExecute

 private void UnsafeExecute()
 {
     PendingCalls = 0;
     foreach (var user in Task.Accounts)
     {
     #if BACKGROUND_AGENT
         ITwitterService service = new TwitterService(SensitiveData.ConsumerToken, SensitiveData.ConsumerSecret,
             user.Key, user.Secret);
     #else
         ITwitterService service = ServiceDispatcher.GetService(user);
     #endif
         service.SendTweet(Task.Text, Task.InReplyTo, ReceiveResponse);
         PendingCalls++;
     }
     if (PendingCalls == 0 && Completed != null)
         Completed(this, new EventArgs());
 }
開發者ID:Quertz,項目名稱:Ocell,代碼行數:17,代碼來源:TaskExecutor.cs

示例13: PostMessage

        public ActionResult PostMessage(string code, string oauth_token, string oauth_verifier)
        {
            if (string.IsNullOrEmpty(code))
            {
                var requestToken = new OAuthRequestToken {Token = oauth_token};
                var service = new TwitterService(ConfigurationManager.AppSettings["TwitterConsumerKey"],
                                                 ConfigurationManager.AppSettings["TwitterConsumerSecret"]);

                OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);

                service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
                service.SendTweet(string.Format("{0} {1}{2}", CurrentPost.Message,
                                                ConfigurationManager.AppSettings["SiteUrl"], CurrentPost.Link));
            }
            else
            {
                var tokens = new Dictionary<string, string>();

                string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}",
                    ConfigurationManager.AppSettings["FbAppId"], Request.Url.AbsoluteUri,
                    ConfigurationManager.AppSettings["FbScope"],
                    code,
                    ConfigurationManager.AppSettings["FbAppSecret"]);

                var request = WebRequest.Create(url) as HttpWebRequest;

                using (var response = request.GetResponse() as HttpWebResponse)
                {
                    var reader = new StreamReader(response.GetResponseStream());

                    string vals = reader.ReadToEnd();

                    foreach (string token in vals.Split('&'))
                    {
                        tokens.Add(token.Substring(0, token.IndexOf("=")),
                            token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
                    }
                }

                var client = new FacebookClient(tokens.FirstOrDefault().Value);

                client.Post("/me/feed", new { message = string.Format("{0} {1}{2}", CurrentPost.Message, ConfigurationManager.AppSettings["SiteUrl"], CurrentPost.Link) });

            }
            return RedirectToAction("Index", "Home");
        }
開發者ID:Vnuuk,項目名稱:VStagram,代碼行數:46,代碼來源:SocialController.cs

示例14: Execute

        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull((object) context, "context");
            if (context.Items.Length != 1)
                return;
            Item item = context.Items[0];

            var scService = new SitecoreService(item.Database);
            var settings = scService.GetItem<TwitterSettings>(SettingsPath);

            TwitterService twitterService = new TwitterService(settings.ConsumerKey, settings.ConsumerSecret);
            twitterService.AuthenticateWith(settings.AccessToken, settings.AccessTokenSecret);

            TwitterUser user = twitterService.VerifyCredentials(new VerifyCredentialsOptions());

            var tweet = scService.CreateType<SendTweetOptions>(item);
            twitterService.SendTweet(tweet);
        }
開發者ID:simonproctor,項目名稱:VirtualSummit,代碼行數:18,代碼來源:TweetCommand.cs

示例15: Tweet

        public static void Tweet(this Beer beer, string message)
        {
            if (message.Length > 140)
                throw new ArgumentOutOfRangeException("Tweet must have at maximum 140 characters.");

            TwitterService tw = new TwitterService(
                ConfigurationManager.AppSettings["TwitterConsumerKey"],
                ConfigurationManager.AppSettings["TwitterConsumerSecret"]);

            var requestToken = tw.GetRequestToken();

            //tw.AuthenticateWith(requestToken.Token, requestToken.TokenSecret);

            tw.AuthenticateWith(
                ConfigurationManager.AppSettings["TwitterToken"],
                ConfigurationManager.AppSettings["TwitterTokenSecret"]);

            TwitterStatus ts = tw.SendTweet(message);
        }
開發者ID:bernardobrezende,項目名稱:IntroDotNetCSharp,代碼行數:19,代碼來源:BeerExtensions.cs


注:本文中的TweetSharp.TwitterService.SendTweet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。