Instagram-private-api: Add Support for Stories Upload

Created on 10 Dec 2017  路  35Comments  路  Source: dilame/instagram-private-api

This package should have support for uploading photos and videos to one's user story.

Most helpful comment

Is it possible to upload a story with a link?

All 35 comments

I totally agree and willing to contribute if necessary

The Instagram API library in PHP has already implemented this feature. Maybe something could be done to port this functionality over to Javascript?

Any ideas? I tried to give it a shot but I can barely understand what's happening here at all.
```PHP
public function uploadPhoto(
$photoFilename,
array $externalMetadata = [])
{
return $this->ig->internal->uploadSinglePhoto(Constants::FEED_STORY, $photoFilename, null, $externalMetadata);
}

Any ideas, @sppmaster?

Not really, my IT team is currently looking to fix other. If anything new I'll keep you updated!

Okay, I found that jlobos/instagram-web-api has implemented this like the following

uploadStory({ photo, caption = '' }) {
  return this._uploadPhoto({ photo }).then(({ upload_id }) =>
    this.request.post('/create/configure_to_story/', {
      form: { upload_id, caption }
    })
  )
}

No news on how to upload videos, however.

Alright, I implemented a working function for uploading stories as photos.

UserStory.prototype.postPhoto = function (photo, caption = '') {
    var that = this;
    return Upload.photo(that.session, photo).then((upload) => {
        var upload_id = upload.params.uploadId;
        return new Request(that.session)
            .setMethod('POST')
            .setResource('createStory')
            .setData({
                upload_id,
                caption,
                'source_type': '3',
                'configure_mode': '1'
            })
            .generateUUID()
            .signPayload()
            .send()
            .then(function(data) {
                return data.media;
            });
    })
};

The only issue now is that I can't figure out how to make Upload.video() work for uploading video stories. It keeps spitting errors and I'm not sure why.

@ciolt is upload photos to strory working ??

@elmissouri You'd have to implement the code in my last comment in order for story photo uploads to work, but yes it does make it work. Video uploads, however, don't work even if I try to implement it.

@ciolt I just got "Unhandled rejection Error: Url with key createStory is not available"

@checho221 Please use this repo for my supported implementation of story uploads.

@ciolt if you put an exapmple on README of working UserStory.postPhoto() i would pull reques fixing challenge.

Sure, I'll let you know when that's finished.

@checho221 I tried but didn't work i well be happy if you share with how implement it exactly im new on node js so i tried but didnt work

@elmissouri16 just use the same README example for Upload.photo but with the Client.Media.configurePhotoStory method

@elmissouri16 oh sorry were you asking for challenge?

@checho221 oh ok thanks i well try it

@checho221 its give me this error **Unhandled rejection TypeError: width.toFixed is not a function**

you just have to do Upload and then Client.Media.configurePhotoStory(session, upload.params.uploadId);

@checho221 Please use this code as an example for story uploads for now.

var userIDs = [ 123456, 654321, 321, 123 ]; // creates array of IDs from which to retrieve stories
var stories = new Client.Feed.UserStory(session, userIDs);

stories.postPhoto('../image/to/jpeg/image.jpg', 'optional caption').then((media) => {
  // do something with media
  console.log(media);
});

@ciolt still the same i got "Unhandled rejection Error: Url with key createStory is not available"

That's odd, I'll see what I can do.

I have the same need. @ciolt Did you get a chance to look into this?

@ciolt replace setResource('createStory') with setResource('mediaConfigureStory')

@elmissouri16 that worked. How were you able to discover that?

,

was already implement #153 here and i discover it by searching :)

@elmissouri16 ahh I see

if (story == true) { return new Request(session) .setMethod('POST') .setResource('mediaConfigureStory') .setBodyType('form') .setData(JSON.parse(payload)) .generateUUID() .signPayload() .send() }

@checho221 Yeah took me some digging to see this is a nice way to do it!

Client.Feed.UserStory.prototype.postPhotoStory = function(photo, caption = "") {
    var that = this;
    return Client.Upload.photo(that.session, photo).then(upload => {
        return Client.Media.configurePhotoStory(
            that.session,
            upload.params.uploadId
        ).then(data => {
            console.log(data);
            return data;
        });
    });
};

@ciolt Has there been any new discoveries for posting video stories? I am also getting errors.

i am just doing Client.Media.configurePhoto(session, upload.params.uploadId, caption)

@checho221 that is posting to your stories? I think that would post to your main feed. Wouldnt you need configurePhotoStory

oh i am sorry, i got Client.Media.configurePhotoStory(session, upload.params.uploadId)

Is it possible to upload a story with a link?

Any plans to add video story support? Looks like source_type needs to be changed to 4 and a thumbnail also needs to be uploaded. Probably a few more things as well.

Relevant Links:

https://github.com/mgp25/Instagram-API/blob/b8eaa610d37d3dff02f302e59080b9b71fb0d99e/src/Request/Internal.php#L643
https://github.com/mgp25/Instagram-API/blob/b8eaa610d37d3dff02f302e59080b9b71fb0d99e/src/Request/Internal.php#L447

Hello, @FerroO2000 ! Is it possible to link IGTV videos in Instagram Stories?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sagardalal21 picture sagardalal21  路  39Comments

dhillon2325 picture dhillon2325  路  14Comments

DenisKrsk picture DenisKrsk  路  33Comments

MMrR0b0TT picture MMrR0b0TT  路  18Comments

ozican picture ozican  路  143Comments