Instagram API from client side

后端 未结 2 1155
陌清茗
陌清茗 2021-01-05 23:50

I\'m trying to call Instagram API endpoints from the client side. I can only access GET-based endpoints using JSONP, which Instagram recommends. For those requiring POST o

相关标签:
2条回答
  • 2021-01-06 00:04

    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');
          }
    
          }
        });
    
    0 讨论(0)
  • 2021-01-06 00:26

    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.

    0 讨论(0)
提交回复
热议问题