Bad Authentication data on second tweet #36

maidbloke opened this Issue Jan 28, 2014 · 5 comments

3 participants


Thanks for the great library.

Using version 3.2.

Works for first tweet in code, second tweet immediately afterwards gives "Bad Authentication data" error message.

TEST CODE (taken from live site and reduced to test case):

$tweet_text .= "Test 1";
echo "Tweeting " . $tweet_text . "\n";
$result = post_tweet($tweet_text);

$tweet_text = "Test 2";
echo "Tweeting " . $tweet_text . "\n";
$result = post_tweet($tweet_text);


Tweeting Test 1
Tweeting Test 2
Error: Bad Authentication data

First tweet is accepted by Twitter and posted, second is not.

Included file post_tweet.php contains only:

function post_tweet($tweet_text) {

    # See twitter-php:

    require_once 'twitter.class.php';
    require_once 'twitterkeys.php';

    $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);

    try {
        $tweet = $twitter->send( $tweet_text );

    } catch (TwitterException $e) {
        echo 'Error: ' . $e->getMessage();


I searched for information about the minimum time allowed between tweets but could only find references to minimum time allowed between identical tweets (tweets in the test code are not identical).

Any ideas?

Thank you

dg commented Mar 10, 2014

You use a method post_tweet twice and variables $consumerKey, $consumerSecret, $accessToken, $accessTokenSecret loaded only once, because you use require_once, apparently that's the problem

dg commented May 22, 2014

Good point!


Thanks dg and alexmorbo. According to
"We [Twitter] don't disclose the length of the windows or how many tweets are allocated to them."
So I had assumed Twitter was throwing away the second one because it decided tweets were coming too quickly. But maybe not...

@alexmorbo how should I change my test code (the first block of code in my question) to correct the error?

dg commented May 23, 2014

require_once 'twitterkeys.php' -> require 'twitterkeys.php'

@dg dg closed this Nov 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment