2

I am grabbing a a users twitter feed, and then cache it for 5 min. So I only actually connect to twitter 12 times an hour...

But I still get the message

Rate limit exceeded. Clients may not make more than 150 requests per hour.

back in my feed. I assume that this is because I am on a shared server and its that servers IP that the limit is based on.

Previously we could just set the user/pass in our curl option

curl_setopt($ch,CURLOPT_USERPWD,$username.':'.$password);

And this would put the 150 limit on that user instead of the shared server IP, But twitter no longer supports basic auth in favor of oAuth..

I dont want to have to set up a whole "app" with key/secret/token etc.. that seem like way to much overkill for simply retreating a user feed.. Are there an other options?

Alex
  • 1,535
  • 2
  • 16
  • 26

1 Answers1

1

The simple way would be to use TwitterOAuth. You will have to register an application with Twitter but that will only take a minute.

Once you have twitteroauth.php and OAuth.php downloaded and you have consumer key/secret for your application you can get an access token for your account by clicking on "My access token" when viewing the application details page.

<?php
// Require the TwitterOAuth library. http://github.com/abraham/twitteroauth
require_once('twitteroauth/twitteroauth.php');
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_SECRET);
$tweets = $connection->get('statuses/user_timeline', array('screen_name' => 'twitter'));
abraham
  • 46,583
  • 10
  • 100
  • 152