Keep getting "Bad Authentication Data" error code 215 with Abraham's Twitteroauth


Hi, I’m new at twitter’s API and I don’t get how to make it work.
My goal is to connect to Twitter’s servers and retrieve a record of random tweets over a certain period of time (like 10 minutes) from the public stream.

Now, I signed up, I got the credentials and I wrote the code below using Abraham’s Twitteroauth:


   require ('twitteroauth/twitteroauth.php');

   $consumerkey = '////////////';
   $consumersecret = '/////////////';
   $accesstoken = ' ////////////////';
   $accesstokensecret = '/////////////////';

    $connection = new TwitterOAuth($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);

    $connection->host = "";
    $connection->ssl_verifypeer = TRUE;
    $connection->content_type = 'application/x-www-form-urlencoded';

   //sample should return a random set of tweets
	$content = $connection->get(' ');
    print_r ($content);

When I run this script, I get this error message:
[message] => Bad Authentication data
[code] => 215

I know this question has been asked lots of times before but I don’t seem to get any outcome anyway. Any tip?


TwitterOAuth doesn’t support the streaming API, I recommend looking at