【问题标题】:Instagram API - How to Setup a Proxy Server for POST Request to Follow a UserInstagram API - 如何为 POST 请求设置代理服务器以关注用户
【发布时间】:2015-03-31 12:07:33
【问题描述】:

我正在使用以下代码让用户关注另一个 Instagram 用户。但是,即使结果返回成功(meta.code==200),API 仍然不允许关注。

我现在明白这是因为 JSONP 使用的是脚本标签和 GET。是设置代理服务器的解决方案吗?如果是这样,你能演示一下如何做到这一点的代码吗?

非常感谢!

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

    url: 'https://api.instagram.com/v1/users/' + followID + '/relationship?access_token=' + accessToken + '&callback=callbackFunction',

    data: {action: 'follow'},/*need this to access the relationship*/
    dataType: "jsonp", 
    success: function(result){
        if (result.meta.code == 200) {
            document.getElementById(followID).innerHTML = "Requested";
            document.getElementById(followID).style.display = "none";
            document.getElementById("reqID" + followID).style.display = "block";
            alert(result.data.outgoing_status;);
        }
    }
});

【问题讨论】:

    标签: api instagram proxy-server


    【解决方案1】:

    在 javascript 中暴露用户访问令牌存在安全风险

    What are the security risks in exposing facebook user access token in javascript?

    访问令牌是敏感数据,必须始终不可见。

    你应该通过服务器端(如 PHP、ASP、JSP……)来做这件事


    这是 Instagram API 的 PHP 包装器,它可能会对您有所帮助

    https://github.com/cosenary/Instagram-PHP-API

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-20
      • 2020-04-19
      • 2018-07-06
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 2012-06-18
      相关资源
      最近更新 更多