Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double posting when posting an image. #284

Closed
MrSleeps opened this issue Jun 29, 2019 · 3 comments
Closed

Double posting when posting an image. #284

MrSleeps opened this issue Jun 29, 2019 · 3 comments

Comments

@MrSleeps
Copy link

Can post to Twitter fine, status posts once, post an image and I get 2 tweets of exactly the same content, both with pictures..

I cannot for the life of me figure out why..

$twitterSettings = array(
    'oauth_access_token' => "token",
    'oauth_access_token_secret' => "secret",
    'consumer_key' => "key",
    'consumer_secret' => "secret"
);
$twitterApiExchange = new TwitterAPIExchange($twitterSettings);
$thisWeeksPicURL = 'https://some.url/thisweekpicture';
$thisWeeksPic = '/full/page/to/image/thisweeks.jpg';
file_put_contents($thisWeeksPic, file_get_contents($thisWeeksPicURL));
$data   = base64_encode(file_get_contents($thisWeeksPic));
$url    = 'https://upload.twitter.com/1.1/media/upload.json';
$method = 'POST';
$params = array(
    'media_data' => $data
);			
$picDataRaw   = $twitterApiExchange->request($url, $method, $params);	

$picData = json_decode($picDataRaw, true, 512, JSON_BIGINT_AS_STRING);

$mediaId = $picData['media_id'];
$url    = 'https://api.twitter.com/1.1/statuses/update.json';
$method = 'POST';
$params = [
    'status' => 'Status Text',
    'possibly_sensitive' => false,
    'media_ids' => $mediaId
];
$data     = $twitterApiExchange->request($url, $method, $params);

Any clues?

@MrSleeps
Copy link
Author

I have narrowed this down to my NGINX and php-fpm set up, for those that have the same issue. Not worked out what yet.. Tried it with Apache and the php module and it didn't double post.

@Thunder33345
Copy link

it might be executed twice for whatever reason in one visit, consider looking into your setup

@MrSleeps
Copy link
Author

MrSleeps commented Jul 1, 2019

It's always the simplest things. Was an extension in my browser.. fml

@MrSleeps MrSleeps closed this as completed Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants