Android: Uploading video from my app using Twitter Kit sdk

android
media-upload

#1

Hello,

I have an Android app and I integrated Fabric sdk in order to authenticate with Twitter. Also I’m creating a small video in the app and I want to tweet\upload video to Twitter. How can achieve this, I didn;t find any api samples in documentation?.

Thank you.


#2

Hey @CaptainSiv, video uploads aren’t currently built-in to Twitter Kit but you can extend Twitter Kit and use the media/uploads endpoint to upload a video.


#3

Hi alexsinger,

Thank your for your response.I followed your instructions and I was able to requesti INIT method, I get the media_id response but when I call APPEND method I get "Invalid command HTTP error 400"
Code snippets:

@Multipart
@POST("https://upload.twitter.com/1.1/media/upload.json")
void uploadVideoAppend(@Part("command") String command,
                                        @Part("media_id") String mediaId,
                                        @Part("segment_index") String segmentIndex,
                                        @Part("media") RequestBody media 
                                        );

requestBody = new RequestBody() {
                    @Override
                    public MediaType contentType() {
                        return MediaType.parse("video/mp4");
                    }

                    @Override
                    public void writeTo(final BufferedSink sink) throws IOException {
                        sink.write(data, 0, fileSize);
                    }
                };

            
                apiService.uploadVideoAppend("APPEND", String.valueOf(mediaId), String.valueOf(0), requestBody)

Android Tweet Video
#4

Hi,

It was my mistake in calling retrofit methods. All methods for video upload is now working well, but I can’t see my video on Twitter account.

Thank you.


#5

You need to post a new Tweet with the mediaId attached.


#6

Thank you andypiper for your response,

What API should I use to post a new Tweet without using TweetComposer?

Thank you again.


#8

I found it. You can close the topic.Thank you


#10

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.