How to post photo to instagram using js?

Viewed 8702

I know that there is no api function to send the photo. But maybe there are some methods to do this from JS?

2 Answers

Now Instagram does allow Content Publishing from their API.

Example from docs:

API Example

Let's say you have a photo at https://www.example.com/images/bronz-fonz.jpg that you want to publish with the hashtag "#BronzFonz" as its caption. You could use the POST /{ig-user-id}/media endpoint to create the container like this:

Sample Request

POST graph.facebook.com/17841400008460056/media
  ?image_url=https//www.example.com/images/bronz-fonz.jpg
  &caption=#BronzFonz

This would return a container ID (let's say 17889455560051444), which you would then publish using the POST /{ig-user-id}/media_publish endpoint, like this:

Sample Request

POST graph.facebook.com/17841405822304914/media_publish
  ?creation_id=17889455560051444

Wrapping those with JS shouldn't be a problem.

var userFeed = new Instafeed({
  get: 'user',
  target: "instafeed-container",
  resolution: 'low_resolution',
  accessToken: 'your generated token'
});
userFeed.run();
a img {
  width: 25%;
}
<!DOCTYPE html>
<html>

<head>
  <title>Instafeed on Your Website</title>
  <script src="https://cdn.jsdelivr.net/gh/stevenschobert/instafeed.js@2.0.0rc1/src/instafeed.min.js"></script>
</head>

<body>
  <h1 style="text-align: center">Instagram Feed</h1>
  <div id="instafeed-container"></div>
</body>

</html>

Related