Processing
 

How to publish more than one picture on Twitter with PHP

25/08/2016 15:15#1

Falken

Member

Joined at: 7 months ago

Post: 2

Thank: 0

Thanked: 0

I already know how to publish a picture with PHP on my twitter account. I use twitteroauth and it works fine with this code.

$with_media = ''; $texte = ltrim(rtrim($line["texte"]));  if($line["image"] > 0) {      $image = strval($line["image"]);     $file = 'twitpic/' . $image . '.jpg';   // this is path of local file     $type = 'jpg';      // jpg     $name = $image . '.jpg'; // image.jpg     $media = '@' . realpath($file) . ';type=image/' . $type . ';filename=' . $name;     $with_media = '_with_media'; }  $status = $texte . ' - ' . $turl; $params = array('media[]' => $media, 'status' => $status); $code = $tmhOAuth->request( 'POST', 'https://api.twitter.com/1.1/statuses/update' . $with_media . '.json', $params, true, true); // use_auth and multipart 

Ok.. May be it's not the best coding.. but it works.

So, now, after many tries, I try to figure myself how to publish up to 3 pictures at the same time. Tried many different things, but never succeed. I don't even know if it's possible.

Anyone could help ? And may be explain how to publish .GIF the same way ?

Thanks a lot.

FZ

26/08/2016 09:30Top#2

Joined at: 10 months ago

Post: 255

Thank: 0

Thanked: 0

You are using a deprecated API - the update_with_media option is no longer supported.

According to the documentation, here is what you have to do.

  1. Upload an image to Twitter
  2. Get a media_id_string in response.
  3. Repeat for up to 4 images.
  4. Use statuses/update to create your tweet - with the parameter media_ids set to the IDs of the uploaded images.

That will let you post multiple still images to Twitter. You can only post one GIF or Video at a time though.

Similar articles

How do twitter giveaways work?

8 months ago - Reply: 2 - Views: 126

How may I get genuine followers on Twitter?

3 years ago - Reply: 33 - Views: 1,828

Login to Twitter sometime fail

6 months ago - Reply: 1 - Views: 23

Twitter doesn't accept PHP's cURL, but Linux'

1 year ago - Reply: 2 - Views: 90

Twitter OAuth on iOS

5 months ago - Reply: 1 - Views: 92

why am i getting an error on .verifyCredentials()

5 months ago - Reply: 1 - Views: 35

TwitteR setup_twitter_oauth() gives an error

5 months ago - Reply: 1 - Views: 29

Tweepy - Getting the author of a retweeted tweet

5 months ago - Reply: 0 - Views: 4

Retrieving data from twitter with JavaScript

5 months ago - Reply: 0 - Views: 2

Combined social media feed returning the wrong data

5 months ago - Reply: 0 - Views: 0

Django and Twitter request_token

5 months ago - Reply: 0 - Views: 0

Python HMAC hashed value encoding to base64

5 months ago - Reply: 1 - Views: 32

At the rate symbol in facebook

5 months ago - Reply: 0 - Views: 1

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re