instagram-private-api icon indicating copy to clipboard operation
instagram-private-api copied to clipboard

From story add to highlight reel

Open jhubert41 opened this issue 1 year ago • 1 comments
trafficstars

General Question

Read the Notes and fill out the form. Switch to Preview for reading.

Notes

Your issue will be closed if you violate any rule below.

  • You need to include a meaningful descriptions and e.g. a screenshot.
  • You do not include screenshots of your code.
  • Read the Docs.
  • Capturing endpoints and similar can be found here (read it if you are going to ask about it).
  • You can delete this section after reading it.

Form

Put an [x] if you meet the condition, else leave [ ].

Question

I am having trouble adding to my highlight reel using edit Reel.

I am able to post to my story with no issuse using ig.publish.story but when I want to add that story to one of my reels using a specific highlightid I am getting undefined as the error. I am using ig.highlights.editReel.

Code

Snippet:

const buffer = canvas.toBuffer('image/jpeg');
     const publishResult = await ig.publish.story({
                    file: buffer
                  });
              
                  if (publishResult.status === 'ok' && publishResult.media && publishResult.media.id) {
                    const mediaId = publishResult.media.id;
                    console.log(`Published to Instagram story successfully. Media ID: ${mediaId}`); // Log publishing success
                    let highlightId = instagramHighlightReels[message.author.id]; 
                    console.log(`${highlightId}`);

//correct id printed to log

                   let mediaIdParts = mediaId.split('_');
                    let extractedMediaId = mediaIdParts[0];
                    console.log(`${extractedMediaId}`);
                    // This is the actual media ID needed and looks correct.
                  if (highlightId) {
                      try {
                        // Attempt to edit the reel with the given highlightId and mediaId
                        await ig.highlights.editReel({
                          highlightId: highlightId,
                          added: [extractedMediaId],
                        });
                        console.log(`Story added to existing Highlight Reel ID: ${highlightId}`);
                      } catch (publishError) {
                        // Here is the error logging part that might be causing the undefined log
                        console.error(`Error while publishing story:`, publishError.response ? publishError.response.data : publishError);
                      }
                    }
                  }

Error and Output

Error whil publishing story: undefined

YOUR WELL FORMATTED ERROR
YOUR OUTPUT GOES HERE

jhubert41 avatar Feb 13 '24 19:02 jhubert41

Any help on the above would be greatly appreciated.

jhubert41 avatar Feb 19 '24 20:02 jhubert41