What Parameters Will Twitter Lib's Fetchtweets() Method Accept
Solution 1:
Yes, it looks like you've uncovered a legit bug on that one. If you look at the execution transcript after running fetchTweets() with a min_retweets search query, it comes out looking like this:
https://api.twitter.com/1.1/search/tweets.json?count=5&include_entities=false&result_type=recent&q=lang%3Aen%20min_retweets%3A100%2520swag
That extra %25
is the percent sign itself getting re-escaped, and it's breaking the query. I'm going to have to go back and comprehensively reexamine all of the special characters; I'm pretty sure some have to be double-escaped and some must not. In the meantime, here's a workaround. You can call twit.fetch and feed it the URL directly, like this:
var tweets = JSON.parse(
twit.fetch(
"https://api.twitter.com/1.1/search/tweets.json?"
+ "count=5&result_type=recent&q="
+ Twitterlib.encodeString("lang:en min_retweets:100 #swag"),
{method: "get"}).getContentText("UTF-8")
).statuses;
I'll also come back and let you know when v22 drops and fixes your issue. Thanks for using my library!
Solution 2:
I checked this for other characters (/#@;$,?=+) and got their respective execution transcript as:
%252F%2523%2540%253B%2524%252C%253F%253D%252B
So the percent sign is getting re-escaped.
Only for ":" it is working properly.
In the fetchtweets function:
var phrase = encodeString('lang:' + (options && options.lang || 'en') + ' ' + encodeString(search).replace(/%3A/g, ":"));
Here ":" is replaced with %3A which comes out to be correct. Maybe adding the same for other characters will work too?
Also, the workaround script takes too long to execute and doesn't always return recent tweets. I got some tweets that had been tweeted around 3 months back!
Post a Comment for "What Parameters Will Twitter Lib's Fetchtweets() Method Accept"