How to fetch latest Twitter trends using PHP: Twitter API Part 2

fetch latest Twitter trends using PHP

This is the third article of Twitter API series. I already published article on Twitter Login with PHP and Tweet using PHP and Twitter API. In this article, I will tell you how to get latest trends of any location using Twitter API and PHP.

If you have not read the previous two articles of Twitter API, you must. It is because I will not repeat the process of obtaining the token and secret. These things are essential for using the API.

Twitter shows location based trends. So, you need to specify a location for getting the trends of that location. But it uses WOEID as location input. So, you need to know the WOEID of that location. You can use this link to search the WOEID of any city.

When you have WOEID, you can use the code given below to fetch the latest trends. This code will work only if you use same twitteroauth.php and config.php file.

$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $row['token'], $row['secret']);
$content = $connection->get('account/verify_credentials');
$r = $connection->get('trends/place', array('id' => '2295019'));

I have already explained how to obtain secret and token in the first tutorial. If you have not read that, you will find this code hard to understand.

Tags: | |

Deepanker Verma is the founder of Techlomedia. He is a tech blogger, developer and gadget freak.

Similar Articles


Leave a comment

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.

2020 UseThisTip | Part of Techlomedia Internet Pvt Ltd Developed By Deepanker