Getting top twitter trends by country

2019-03-14 05:24发布

I know how to get trends using API, but i want it by country and top 10.

How can I ? Is that possible?

Tried this one but not working

http://api.twitter.com/1/trends/current.json?count=50

标签: twitter
3条回答
劳资没心,怎么记你
2楼-- · 2019-03-14 05:33

Yes, you can.

First, figure out which countries you want to get data for.

Calling

https://dev.twitter.com/docs/api/1/get/trends/available

Will give you a list of all the countries Twitter has trends for.

Suppose you want the trends for the UK. The above tells us that the WOEID is 23424975.

To get the top ten trends for the UK, call

https://api.twitter.com/1/trends/23424975.json
查看更多
不美不萌又怎样
3楼-- · 2019-03-14 05:35

you need to figure out the woeids first use this tool here http://sigizmund.info/woeidinfo/ and then it becomes as easy as a simple function

function get_trends($woeid){
        return json_decode(file_get_contents("http://api.twitter.com/1/trends/".$woeid.".json?exclude=hashtags", true), false); 
    }

Here you go, I wrote a simple sample script for you. Check It Out Here Twitter Trends Getter

Hope it helps!

查看更多
别忘想泡老子
4楼-- · 2019-03-14 05:49

Note that Twitter API v1 is no longer functional. Read announcement
So you should use Twitter API 1.1.

REST method is this: GET trends/place

https://dev.twitter.com/docs/api/1.1/get/trends/place

You should authenticate with access tokens to reach this data.

查看更多
登录 后发表回答