Count number of Tweets from the past 30 days using Twurl

此生再无相见时 提交于 2020-04-05 06:33:00

问题


To request tweets from the Standard search API with a specific hashtag, I've done

twurl "/1.1/search/tweets.json?q=#jesus"

Tht worked fine. Now wanting to use the Premium search APIs to count the tweets from the past 30 days with the hashtag jesus.

In it, there's a Counts endpoint, /search/:label/counts.

For the tweets from the past 30 days, that's the endpoint pattern, /search/30day/:label/counts.json.

I've created a Search Tweets: 30-Days Sandbox with name stackoverflow (that is the label).

Then, when running the following

twurl "/1.1/tweets/search/30day/stackoverflow/counts.json?query=#jesus"

I get

{"error":{"message":"Unauthorized: Stream is not enabled for count requests","sent":"2020-02-26T13:26:57+00:00","transactionId":"00f67ea10058270b"}}

From this, decided to go to the app keys and tokens and regenerated both Consumer API keys and Access token & access token secret.

After

twurl authorize --consumer-key ************** --consumer-secret *****************

and using the PIN code I get

Authorization successful

If I do again

twurl "/1.1/tweets/search/30day/stackoverflow/counts.json?query=#jesus"

Then get

{"error":{"message":"Invalid or expired token.","sent":"2020-02-26T13:39:44+00:00","transactionId":"00dea42000a8a098"}}

Regenerated again both Consumer API keys and Access token & access token secret but still no success.

How can I do it then?


回答1:


Counts is only available to paid premium accounts, and one needs to pay for premium access.

Use this link to Apply for access.



来源:https://stackoverflow.com/questions/60401145/count-number-of-tweets-from-the-past-30-days-using-twurl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!