本文整理汇总了C#中TwitterService类的典型用法代码示例。如果您正苦于以下问题:C# TwitterService类的具体用法?C# TwitterService怎么用?C# TwitterService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TwitterService类属于命名空间,在下文中一共展示了TwitterService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AuthorizeCallback
public ActionResult AuthorizeCallback(string oauth_token, string oauth_verifier)
{
TwitterService service = new TwitterService(_consumerKey, _consumerSecret);
var requestToken = new OAuthRequestToken {Token = oauth_token};
OAuthAccessToken accessToken = service.GetAccessToken(requestToken, oauth_verifier);
service.AuthenticateWith(accessToken.Token, accessToken.TokenSecret);
TwitterUser user = service.VerifyCredentials();
ViewModel.Message = string.Format("Your username is {0}", user.ScreenName);
return View("Index");
}
示例2: Can_get_public_timeline
public void Can_get_public_timeline()
{
var service = new TwitterService();
var tweets = service.ListTweetsOnPublicTimeline();
Assert.IsNotNull(tweets);
Assert.AreEqual(20, tweets.Count());
Assert.IsNotNull(service.Response);
Assert.AreEqual(HttpStatusCode.OK, service.Response.StatusCode);
var unfavorited = 20;
foreach (var tweet in tweets)
{
Assert.IsNotNullOrEmpty(tweet.RawSource);
Assert.AreNotEqual(default(DateTime), tweet.CreatedDate);
Console.WriteLine("{0} said '{1}'", tweet.User.ScreenName, tweet.Text);
if(tweet.IsFavorited)
{
unfavorited--;
}
}
Assert.IsTrue(unfavorited > 0);
AssertRateLimitStatus(service);
}
示例3: Can_get_media_links_from_entities
public void Can_get_media_links_from_entities()
{
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
var tweet = service.GetTweet(128818112387756032);
Assert.IsNotNull(tweet.Entities);
Assert.AreEqual(1, tweet.Entities.Media.Count);
var media = tweet.Entities.Media[0];
Assert.AreEqual("http://p.twimg.com/AcmnZAXCMAEaDD1.jpg", media.MediaUrl);
Assert.AreEqual("https://p.twimg.com/AcmnZAXCMAEaDD1.jpg", media.MediaUrlHttps);
Assert.AreEqual("http://twitter.com/sarah_hatton/status/128818112387756032/photo/1", media.ExpandedUrl);
Assert.AreEqual("pic.twitter.com/xCdS2Emt", media.DisplayUrl);
Assert.AreEqual(TwitterMediaType.Photo, media.MediaType);
Assert.AreEqual(69, media.Indices[0]);
Assert.AreEqual(89, media.Indices[1]);
Assert.AreEqual("128818112391950337", media.IdAsString);
Assert.AreEqual(128818112391950337, media.Id);
// Sizes
Assert.AreEqual(4, media.Sizes.Count());
Assert.AreEqual("fit", media.Sizes.Large.Resize);
Assert.AreEqual(597, media.Sizes.Large.Height);
Assert.AreEqual(800, media.Sizes.Large.Width);
}
示例4: OnNavigatedTo
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
if (e.Parameter is TwitterService)
{
TwitterClient = e.Parameter as TwitterService;
List<Tweet> lists = await TwitterClient.requestTwitterApi(_getHomeTimelineUrl);
foreach (Tweet tweet in lists)
{
ViewModel.tweets.Add(tweet);
}
List<Tweet> mentions = await TwitterClient.requestTwitterApi(_getMentionsUrl);
foreach (Tweet tweet in mentions)
{
MentionsViewModel.tweets.Add(tweet);
}
List<Tweet> userstweets = await TwitterClient.requestTwitterApi(_getUserTimelineUrl);
foreach (Tweet tweet in userstweets)
{
ProfileViewModel.tweets.Add(tweet);
}
}
else
{
//no tweets
}
base.OnNavigatedTo(e);
}
示例5: Can_parse_ids_greater_than_53_bits
public void Can_parse_ids_greater_than_53_bits()
{
const string json = "{ \"id\": 90071992547409921}";
var status = new TwitterService().Deserialize<TwitterStatus>(json);
Assert.IsNotNull(status);
Assert.AreEqual(90071992547409921, status.Id);
}
示例6: Can_get_reverse_geocode
public void Can_get_reverse_geocode()
{
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
var places = service.ReverseGeocode(45.42153, -75.697193).ToList();
Assert.IsNotEmpty(places);
Assert.AreEqual(4, places.Count);
places = places.OrderBy(p => p.Id).ToList();
Assert.AreEqual("Ottawa, Ontario", places[0].FullName);
Assert.AreEqual(TwitterPlaceType.City, places[0].PlaceType);
Assert.AreEqual("06183ca2a30a18e8", places[0].Id);
Assert.AreEqual(1, places[0].ContainedWithin.Count());
Assert.AreEqual("89b2eb8b2b9847f7", places[0].ContainedWithin.ToList()[0].Id);
Assert.AreEqual("Canada", places[1].FullName);
Assert.AreEqual("3376992a082d67c7", places[1].Id);
Assert.AreEqual(TwitterPlaceType.Country, places[1].PlaceType);
Assert.AreEqual("Ontario, Canada", places[2].FullName);
Assert.AreEqual(TwitterPlaceType.Admin, places[2].PlaceType);
Assert.AreEqual("Québec, Canada", places[3].FullName);
Assert.AreEqual(TwitterPlaceType.Admin, places[3].PlaceType);
}
示例7: Can_tweet_with_protected_resource_info
public void Can_tweet_with_protected_resource_info()
{
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
var status = service.SendTweet(new SendTweetOptions { Status = DateTime.Now.Ticks.ToString() });
Assert.IsNotNull(status);
}
示例8: Can_get_request_token_async
public async Task Can_get_request_token_async()
{
var service = new TwitterService(_consumerKey, _consumerSecret);
var result = await service.GetRequestTokenAsync();
Assert.AreEqual(result.Response.StatusCode, HttpStatusCode.OK);
Assert.NotNull(result.Value);
}
示例9: Can_get_request_token
public void Can_get_request_token()
{
var service = new TwitterService(_consumerKey, _consumerSecret);
var requestToken = service.GetRequestToken();
AssertResultWas(service, HttpStatusCode.OK);
Assert.NotNull(requestToken);
}
示例10: Can_support_secure_urls_in_entitities
public void Can_support_secure_urls_in_entitities()
{
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
var tweet = service.GetTweet(131501393033961472);
Console.WriteLine(tweet.RawSource);
}
示例11: Authorize
public ActionResult Authorize()
{
TwitterService service = new TwitterService(_consumerKey, _consumerSecret);
OAuthRequestToken requestToken = service.GetRequestToken();
var uri = service.GetAuthorizationUri(requestToken);
return new RedirectResult(uri.ToString(), false /*permanent*/);
}
示例12: GetTweets_Can_Successfully_Retrieve_Values_From_Twitter
public void GetTweets_Can_Successfully_Retrieve_Values_From_Twitter()
{
var query = "#ltnet";
var twitterService = new TwitterService();
var tweets = twitterService.GetTweets(query, this.date);
Assert.That(tweets.Count(), Is.GreaterThan(0));
}
示例13: GetTweers_Returns_Empty_List_When_No_Results_Found
public void GetTweers_Returns_Empty_List_When_No_Results_Found()
{
var empty = 0;
var query = "#hashtagfortesting";
var twitterService = new TwitterService();
var tweets = twitterService.GetTweets(query, this.date);
Assert.AreEqual(empty, tweets.Count());
}
示例14: GetTweers_Returns_Empty_List_When_Internal_Exception_Happens
public void GetTweers_Returns_Empty_List_When_Internal_Exception_Happens()
{
var empty = 0;
string query = null;
var twitterService = new TwitterService();
var tweets = twitterService.GetTweets(query, this.date);
Assert.AreEqual(empty, tweets.Count());
}
示例15: GetTweetsOnHashTags
public string GetTweetsOnHashTags(string hashTags)
{
var service = new TwitterService(consumerKey, consumerSecret);
service.AuthenticateWith(accessToken, accessTokenSecret);
SearchOptions so = new SearchOptions();
so.Q = "#"+hashTags;
so.Count = 100;
var tweeting = service.Search(so);
IEnumerable<TwitterStatus> returnValue = tweeting.Statuses;
TweetsInst tweets = null;
MulTweetInstance multweets = new MulTweetInstance();
foreach (var twt in returnValue)
{
tweets = new TweetsInst();
if (twt.Author.ScreenName != null)
{
tweets.author = twt.Author.ScreenName;
}
else { tweets.author = ""; }
if (twt.Author.ProfileImageUrl != null)
{
tweets.UserImage = twt.Author.ProfileImageUrl;
}
else { tweets.UserImage = ""; }
if (twt.User != null)
{
tweets.User_ID = Convert.ToString(twt.User.Id);
}
else { tweets.User_ID = null; }
if (twt.Text != null)
{
tweets.tweet = twt.Text;
}
else { tweets.tweet = ""; }
if (twt.Location != null)
{
tweets.latitude = Convert.ToString(twt.Location.Coordinates.Latitude);
}
else { tweets.latitude = ""; }
if (twt.Location != null)
{
tweets.longitude = Convert.ToString(twt.Location.Coordinates.Longitude);
}
else { tweets.longitude = null; }
if (twt.Place != null)
{
tweets.country = twt.Place.Country;
}
else { tweets.country = ""; }
multweets.mulTweet.Add(tweets);
}
string output = JsonConvert.SerializeObject(multweets);
return output;
}