Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bad Authentication data on second tweet #36

Closed
maidbloke opened this Issue · 5 comments

3 participants

Paul Baker David Grudl Alex Morbo
Paul Baker

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";
require_once("/home/maidhous/public_html/includes/twitter/post_tweet.php");
$result = post_tweet($tweet_text);

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

OUTPUT:

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:
    # https://github.com/dg/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

David Grudl
Owner
dg commented
Alex Morbo

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

David Grudl
Owner
dg commented

Good point!

Paul Baker

Thanks dg and alexmorbo. According to
https://dev.twitter.com/discussions/20330
"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?

David Grudl
Owner
dg commented

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

David Grudl dg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.