0

I have an app using the twitter rest API. Everything is working fine but we're bumping into rate limits so we need to authenticate using oAuth. I have the oauth token and secret. It's not a consumer facing app and we will only need to authenticate using this token and secret.

My question is how to include the token and secret in the rest request to authenticate?

There's a plenty of documentation on how to obtain the token and secret but I can't find any on how to use them.

applechief
  • 6,615
  • 12
  • 50
  • 70

2 Answers2

2

Using the TwitterOAuth PHP library it is as simple as this:

<?php
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);

$content = $connection->get('account/verify_credentials');

There are several more example requests in the demo index.php.

abraham
  • 46,583
  • 10
  • 100
  • 152
0

Twitter documentation links to a few PHP OAuth libraries that you can use to accomplish OAuth authentication.

sikander
  • 2,286
  • 16
  • 23
  • why -1? First library in the link is to oauth-php and their documentation shows clearly what you need to do once you have the token and secret: http://code.google.com/p/oauth-php/wiki/ConsumerHowTo (step 3) – sikander Mar 20 '12 at 16:56