0

I want the twitter analytics data, some values like:

  • retweets, *followers,
  • demographics and
  • geographic data.

I have Access Tokens for multiple users, and I want to access their data of Twitter Analytics.

I have checked this thread too: C# console application Streaming API 1.1 + Oauth

but my scenario is different, I don't want the data for a single user only, I have multiple users with their access tokens. How can I accomplish this task?

I have seen their Rest API, it's not possible from it. So I have moved towards Twitter's Streaming API, but I have seen many blogs which keeps telling that Twitter's Stream API can't be used via OAuth.

I am using C#.

Community
  • 1
  • 1
Sanjay Bathre
  • 451
  • 1
  • 5
  • 17

1 Answers1

0

It is definitely possible to use OAuth to access the Twitter Stream API. Simply use Tweetinvi, set your credentials and you should be able to access the Streaming API straight away.

TwitterCredentials.SetCredentials(credentials);

var stream = Stream.CreateUserStream();
stream.TweetCreatedByMe += (sender, args) =>
{
    Console.WriteLine("User posted : ", args.Tweet.Text);
};
stream.StartStream();
user2465083
  • 595
  • 3
  • 12
  • Hi, thanx for reply, but in my case i to access the data on behalf of user via their access token, i only have their access token they provided, is it possible to access data via access token only like google or facebook? – Sanjay Bathre Nov 04 '14 at 10:51
  • The code I provided will work on behalf of the user. To create credentials in Tweetinvi you will need to give the information related with the user (AccessToken and AccessTokenSecret) and then give the information concerning your application (ConsumerToken and ConsumerSecret). => TwitterCredentials.SetCredentials("Access_Token", "Access_Token_Secret", "Consumer_Key", "Consumer_Secret"); – user2465083 Nov 04 '14 at 11:04
  • you mean to say at the end we need "Access_Token", "Access_Token_Secret", "Consumer_Key", "Consumer_Secret" (apart from our App. credentials) of the N users registered in my platform? can't it be done only by accesstoken. – Sanjay Bathre Nov 04 '14 at 11:25
  • When you create an application on apps.twitter.com, the application is referenced with 2 information the ConsumerKey and ConsumerSecret. When a user accepts to use the application it creates an AccessToken and AccessTokenSecret that are associated with his account. When you make a query on Twitter you need to provide all these information so that your request to the REST API is authorized by their authentication system. – user2465083 Nov 04 '14 at 12:44
  • If you want to execute the same operation you can simply use the ExecuteOperationWithCredentials : TwitterCredentials.ExecuteOperationWithCredentials(credentials, () => { var userFromCredentials = User.GetLoggedUser(); }); – user2465083 Nov 04 '14 at 12:45
  • :) but as i mentioned i do not want my data, i want other user's (registered and have performed the OAuth in my Website and i have their access tokens) data from their access tokens. – Sanjay Bathre Nov 05 '14 at 13:01
  • Well just use their credentials information as I explained? – user2465083 Nov 05 '14 at 17:08