0

I am trying to build a website that connect with Instagram.

And I want to subscribe Instagram's tag for real time.

curl -F 'client_id=CLIENT-ID' \
 -F 'client_secret=CLIENT-SECRET' \
 -F 'object=tag' \
 -F 'aspect=media' \
 -F 'object_id=nofilter' \
 -F 'callback_url=http://YOUR-CALLBACK/URL' \
 https://api.instagram.com/v1/subscriptions/

I really don't know how to do this in nodejs.

Rosa
  • 642
  • 6
  • 20
Hikaru Shindo
  • 2,611
  • 8
  • 34
  • 59

2 Answers2

3

You'll need the request library for the following code. https://github.com/request/request

var request = require('request');

var formData = {
  client_secret: "CLIENT-SECRET",
  object: "tag",
  aspect: "media",
  "object_id": "nofilter",
  "callback_url": "http://YOUR-CALLBACK/URL"
};

request.post({
  url: "https://api.instagram.com/v1/subscriptions/",
  formData: formData
}, function (err, res, body) {
  if (err) {
    console.log(err);
  } else {
    console.log(body);
  }
});
Transcendence
  • 2,616
  • 3
  • 21
  • 31
1

As others have said, request is likely the easiest solution. However, if you have to use curl directly, the following can work natively:

var spawn = require('child_process').spawn;

var command = spawn('curl', []);

command.stderr.on('data', function(data) { });

command.stdout.on('data', function(data) { });

command.stdout.on('close', function() {  });

See spawn command arguments for more information. Alternatively, node-curl is available.

dzm
  • 22,844
  • 47
  • 146
  • 226