Post video on Twitter APi PHP [closed]

Asked 2 years ago, Updated 2 years ago, 50 views

Do you want to improve this question?Update your question, Edit this post to be answered with facts and quotes.

Closed 5 years ago.

5 years ago

I would like to use the Twitter API to use PHP for video tweets.
Do you have any good materials?

php

2022-09-30 21:24

1 Answers

I have never used PHP, so I will explain the general procedure.

Upload an image and run a two-step API for body tweets.

Upload the image

Use the API https://upload.twitter.com/1.1/media/upload.json.
Normal tweets POST with application/x-www-form-urlencoded but
The parameters that are exported as POST data in regular tweets should be placed in the header Authorization:OAuth~.Replace the delimiter & with ,.Upload the image data body with multipart/form-data.

Successful upload returns JSON data.Obtain and remember the value media_id from it.

Up to 4 images can be uploaded, so repeat as many times as necessary.Obtain up to four media_id.

Tweet the body

As usual, use the API https://api.twitter.com/1.1/statuses/update.json?status= in your tweet.

Add the media ID obtained in the previous process to the request parameter, such as &media_ids=aaaaaa,bbbbb,cccccc,dddd.Up to 4 comma separated

The parameters created in this way are signed by OAuth in the same way as regular tweets.As I mentioned above, POST with application/x-www-form-urlencoded.


2022-09-30 21:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.