Instagram API from client side

偶尔善良 提交于 2019-11-30 21:29:19

Not possible to make POST calls directly from client side, You have to setup a proxy server that makes the Instagram API calls for POST and DELETE, and your client side app can call the proxy server.

I not understand your question, but i use the Instagram API in Client Side, and i make POST and GET, using it:

 $.ajax({
  type: "POST",
  "method": "POST",

  //Use the URL in Instagram Document
  url: 'https://api.instagram.com/v1/media/<ID>/likes?access_token=<TOKEN>',
  dataType: "jsonp", 

  //To get response
  success: function(result){

  //Exemple, if is okay or not
  if(result.meta.code == 200){
  alert('ok');  
  }else{
  alert('fail'); 
  }

  }
});

You can change the token and media id, and test it on http://jsfiddle.net/DvLE2/

If you need send data (action, in relationship), you add:

data: data;

Exemple, for Relationship (to follow or unfollow someone):

$.ajax({
      type: "POST",
      "method": "POST",

      url: 'https://api.instagram.com/v1/users/<ID>/relationship?access_token=<TOKEN>',
      //action (you need that to use relationship 
      data: {action: 'follow'},
      dataType: "jsonp", 
      success: function(result){
      if(result.meta.code == 200){
      alert('ok');

      }else{
      alert('fail');
      }

      }
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!