本文整理汇总了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 });
}
}
示例2: UpdateStatus
public static void UpdateStatus(string tweet, IOAuthCredentials credentials) {
var singleUserAuthorizer = new SingleUserAuthorizer {
Credentials = credentials
};
var twitterCtx = new TwitterContext(singleUserAuthorizer);
twitterCtx.UpdateStatus(tweet);
}
示例3: BindDemo
private void BindDemo()
{
ITwitterAuthorizer autentikasi = GetInformasiKredensial();
var TwitterDataContext = new TwitterContext(autentikasi);
var status = TwitterDataContext.UpdateStatus("Skuad jadi latihan teu?");
}
示例4: Tweet
public string Tweet(ITwitterAuthorizer auth, string status)
{
using (var twitterCtx = new TwitterContext(auth))
{
var tweet = twitterCtx.UpdateStatus(status);
return tweet.StatusID;
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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 });
}
}
示例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);
}
}
示例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]);
}
示例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());
}
示例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;
}
}));
}
}
示例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);
}
}
示例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");
}
示例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());
}
});
}