本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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));
}
示例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;
}
示例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});
}
示例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);
}
示例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;
}
示例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
});
}
示例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);
}
}
示例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);
}
}
示例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());
}
示例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");
}
示例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);
}
示例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);
}