401 Unauthorized Access

Jan 30, 2014 at 5:07 AM
Edited Jan 30, 2014 at 9:27 AM
Hi Linvi,

I've created application with your great library. I follow your instruction in other thread to get tweet from timeline with specific hashtag but this error always comes up.
Image

I have no idea to solve this. i've try to save key in configuration file, i've try to change my timezone, dan try to change access level on dev.twitter.com but doesn't work.

Here my app: LoadHashtag
can you give the clue to solve this?
Coordinator
Jan 30, 2014 at 9:19 AM
Hi,

A 401 Exception is usually related with credentials being incorrect.
I will have a look when I have some time available tonight.

In the meantime please do not put your project as public with your credentials information :)

Sincerely,
Linvi
Jan 30, 2014 at 9:30 AM
i have try my token to do stream twitter, it works. i try to publish tweet it works too. but when i try to get tweet it said 401. still make me confuse..

thanks for fast response, i will wait resolution from you. :)
Coordinator
Jan 30, 2014 at 9:58 AM
Edited Jan 30, 2014 at 10:00 AM
Hi there,

I have read your code and you are currently trying to parse the result on your own because Search of tweet is not provided in 0.8.3.x.
Hopefully the 0.9 (development version) has such a feature and as the release draw nearer I would advise you to use it.

You can only download it from the Source Code download and find examples in Examplinvi as always.

Simple Example using 0.9:
var tweets = Search.SearchTweets("#tweetinvi");

foreach (var tweet in tweets)
{
       Console.WriteLine("{0}", tweet.Text);
}
Complex search example using 0.9:
TwitterCredentials.TokenCredentials = new TokenCredentials(
                ConfigurationManager.AppSettings["token_AccessToken"],
                ConfigurationManager.AppSettings["token_AccessTokenSecret"],
                ConfigurationManager.AppSettings["token_ConsumerKey"],
                ConfigurationManager.AppSettings["token_ConsumerSecret"]);

var searchParameter = Search.GenerateSearchTweetParameter("tweetinvi");

searchParameter.SetGeoCode(Geo.GenerateCoordinates(-122.398720, 37.781157), 1, DistanceMeasure.Miles);
searchParameter.Lang = Language.English;
searchParameter.SearchType = SearchResultType.Popular;
searchParameter.MaximumNumberOfResults = 100;
searchParameter.Until = new DateTime(2013, 12, 1);
searchParameter.SinceId = 399616835892781056;
searchParameter.MaxId = 405001488843284480;

var tweets = Search.SearchTweets(searchParameter);

foreach (var tweet in tweets)
{
    Console.WriteLine("{0}", tweet.Text);
}
Please let me know if this helps you.
Linvi
Jan 30, 2014 at 1:02 PM
this line keep giving me 401 error. i've try with a new token. Grrrr! :(
var tweets= Search.SearchTweets("#tweetinvi");
And this line too
var tweets = Search.SearchTweets(searchParameter);
any idea?
Coordinator
Jan 30, 2014 at 1:46 PM
Hi,

I will have a look tonight and let you know.

Linvi
Coordinator
Jan 30, 2014 at 3:57 PM
Edited Jan 30, 2014 at 4:00 PM
Sorry for the delay,

You helped me identify a bug. I will update the code tonight. In the meantime you can solve your problem this way:
var tweets = Search.SearchTweets("#tweetinvi".TwitterEncode());
You will need to add this namespace:
using TweetinCore.Extensions;
Thank you for the feedback :D
Regards,
Linvi
Marked as answer by linvi on 1/30/2014 at 4:31 PM
Coordinator
Jan 31, 2014 at 12:31 AM
I have updated the Source Code so that search with hashtags work properly.
You can download it in the Source Code section.

Regards,
Linvi
Marked as answer by linvi on 1/30/2014 at 4:31 PM
Jan 31, 2014 at 5:38 AM
thanks for fast response. i will reporting later. :)
Jan 31, 2014 at 5:51 AM
Edited Jan 31, 2014 at 6:02 AM
Great!! it's works now! thank you linvi. GBU.. :)

But, i still have one question.

how to get searchresult without Retweet??
Coordinator
Jan 31, 2014 at 9:57 AM
Hey,

Happy this work for you.

How to get searchresult without Retweet??

If I understand correctly you want to be able to search Twitter but not select any retweet, only original tweet.
I will have a look tonight in the Twitter API Resources to see if there is such a feature but I am not sure.
I will report to you and if there is will implement this tonight or during the weekend.

If you have some time before me please have a look and let me know.

Sincerely,
Linvi
Coordinator
Jan 31, 2014 at 12:40 PM
Edited Jan 31, 2014 at 12:43 PM
Hi,

Twitter does not provide such a feature (using twitter search) consequently instead of having a query sent to twitter that performs this action I will need to filter the results. It means that the number of tweets returned by the query will be less than the maximum number of tweets expected if a filter is applied.

I will post the code when I implemented it tonight but the filtering code should look like this :
var searchParameter = Search.GenerateSearchTweetParameter("#tweetinvi");
searchParameter.TweetSearchFilter = TweetSearchFilter.OriginalTweetsOnly;
var tweets = Search.SearchTweets(searchParameter);
This Feature has been added to the list of taks here, you can subscribe to it to receive an email when this is done (tonight ;).

Regards,
Linvi
Jan 31, 2014 at 2:45 PM
sound goods.. thanks you have notice my thread.. :)
Coordinator
Jan 31, 2014 at 7:12 PM
Hi,

If you download the latest version of tweetinvi from the Source Code you will be able to use the code provided above.
This has not yet been tested so the ticket is not closed yet but you should be able to use it properly :)

Linvi