本文整理汇总了C#中TweetSharp.TwitterService.SearchForUser方法的典型用法代码示例。如果您正苦于以下问题:C# TwitterService.SearchForUser方法的具体用法?C# TwitterService.SearchForUser怎么用?C# TwitterService.SearchForUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TweetSharp.TwitterService
的用法示例。
在下文中一共展示了TwitterService.SearchForUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFavorites
public IEnumerable<TwitterStatus> GetFavorites()
{
var service = new TwitterService(Config.Twitter.ConsumerKey, Config.Twitter.ConsumerSecret);
// Step 1 - Retrieve an OAuth Request Token
var requestToken = service.GetRequestToken();
// Step 2 - Redirect to the OAuth Authorization URL
var uri = service.GetAuthorizationUri(requestToken);
Process.Start(uri.ToString());
// Step 3 - Exchange the Request Token for an Access Token
Console.Write("Please, your key? ");
var verifier = Console.ReadLine(); // <-- This is input into your application by your user
var access = service.GetAccessToken(requestToken, verifier);
// Step 4 - User authenticates using the Access Token
service.AuthenticateWith(access.Token, access.TokenSecret);
var users = service.SearchForUser("kellogh");
if (users == null)
{
Console.WriteLine("No users found");
yield break;
}
var user = users.First();
var favorites = service.ListFavoriteTweetsFor(user.Id);
foreach (var tweet in favorites)
{
yield return tweet;
}
}
示例2: Post
public HttpResponseMessage Post([FromUri]int Id, [FromUri]bool ArtistPost)
{
Proposal currProposal = _db.Proposal.FirstOrDefault(c=>c.Id == Id);
Models.Service service = _db.User.FirstOrDefault(c => c.UserId == WebSecurity.CurrentUserId).Services.FirstOrDefault(c=>c.Provider == "twitter");
if (service != null)
{
TwitterService twitter = new TwitterService(Settings.Settings.TwitterConsumerKey, Settings.Settings.TwitterConsumerSecret, service.Token, service.TokenSecret);
try
{
if (ArtistPost == true)
{
//string message = "test message";
var result = twitter.SearchForUser(currProposal.Artist).ToList();
string message = "@" + result[0].Name.Replace(" ",string.Empty) + " It was suggested tha you play an event at " + currProposal.Venue + " for more info go to www.botf.azurewebsites.net";
twitter.SendTweet(message);
}
else
{
string message = "just suggested the event " + "->"
+ currProposal.Artist + "<-" + " at " + "->" + currProposal.Venue + "<-" + "." + " Like this? Get on board! at " + System.Web.HttpContext.Current.Request.UrlReferrer.ToString();
twitter.SendTweet(message);
}
return Request.CreateResponse(HttpStatusCode.OK);
}
catch (Exception)
{
return Request.CreateResponse(HttpStatusCode.Conflict);
}
}
else
{
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
}