Twitter API [1.1] Authentication Request Severe Problem ---

api-access
tweetsharp

#1

Hello All.

Need good amount of help on this one. Basically in my application, I am required to access twitter api, fetch the top 50 posts as per a specific search tag and display them. Naturally the agenda of authentication comes in. Now this is giving me severe trouble. My code doesn’t work seemingly because of - Bad authentication data [215]. I’ve used the TweetSharp package to form my code.

I’ll post it here –

public class TweetHelper
    {
        public static string _consumerKey = "whatever";
        public static string _consumerSecret = "whatever";
        public static string _accessToken = "whatever";
        public static string _accessTokenSecret = "whatever";
        
public static List<TwitterStatus> GetTweetList1()
        {
            TwitterService twitterService = new TwitterService(_consumerKey, _consumerSecret);
            int tweetcount = 1;
   ---->    var tweets_search = twitterService.Search(new SearchOptions { Q = "#ClimateChange", Resulttype = TwitterSearchResultType.Popular, Count = 50 });
   ---->    twitterService.AuthenticateWith(_accessToken, _accessTokenSecret);

            List<TwitterStatus> resultList = new List<TwitterStatus>(tweets_search.Statuses);
            foreach (var tweet in tweets_search.Statuses)
            {
                try
                {
                    tweet.User.ScreenName.ToString();
                    tweet.User.Name.ToString();
                    tweet.Text.ToString();
                    tweet.RetweetCount.ToString();
                    tweet.User.FavouritesCount.ToString();
                    tweet.User.ProfileImageUrl.ToString();
                    tweet.CreatedDate.ToString();
                    ("https://twitter.com/intent/retweet?tweet_id=" + tweet.Id).ToString();
                    ("https://twitter.com/intent/tweet?in_reply_to=" + tweet.Id).ToString();
                    ("https://twitter.com/intent/favorite?tweet_id=" + tweet.Id).ToString();

                    tweetcount++;
                }
                catch (Exception exp)
                {
                    throw exp;
                }
            }
            return resultList;


        }

}

I know 1.0 API version has been deprecated by twitter. And 2.0 hasn’t arrived. So it has to be 1.1. As you can see, those two are the problem lines, where the error is happening. What am I doing wrong? Or what piece of information from the API versions is it that I’m wrongly approaching? It can’t be that all those keys and tokens, secrets etc are wrong. I copied them correctly all right, while creating my app. If you want to test it in some way I don’t even mind sharing all those keys etc. with you. I’ll simply just delete the old app. and create anew allover; so no problem with that either. Just tell me if you’d need it. I’ve done good bit of google on this but the articles that come up seem kind of off-the-point.
One more thing is that, I’m trying this from my dev. environment on my local machine; where I did an edit of the windows host file to make my application run from that specific IP address and behave like a definite url. I also used this, while filling in the details of the website, domain etc. fields during creating the twitter app.

Kindly help me on this issue. I am finding it tough to get past.
Thanks so much in advance,


#2

there’s a chance that the time on your development machine may not be accurate enough to communicate with the API - OAuth has a time dependency.

Beyond that, I’m not very familiar with TweetSharp myself, so this is difficult to debug - maybe someone else may have a useful clue for you.


#3

Hi @andypiper,

Thanks so much for replying.
Okay, I’m going update the time clock and stuff and check again. As a side measure, also send the same kind of request from a telerik fiddler, postman or something - to see if it returns any data. And if not, what error message;
I’ll revert back.
Thanks.