【问题标题】:Instagram realtime OAuthParameterException: missing client_id or access_token URL parameter. in _requestInstagram 实时 OAuthParameterException:缺少 client_id 或 access_token URL 参数。在_request
【发布时间】:2017-06-07 23:11:23
【问题描述】:

我正在尝试设置 Instagram 实时订阅。我是 NodeJS 的新手,所以想从 GitHub 设置项目。我已经尝试了几个 repos,它们都以同样的错误告终。

OAuthParameterException occurred: Missing client_id or access_token URL parameter. in _request

我目前使用的代码来自:https://github.com/weblancaster/instagram-real-time

我首先注册了我的应用程序,我为我的回调 url 设置了一个 heroku 实例,获得了范围为 public_content 和 follower_list 的 access_token。

server.js 中,我用从https://www.instagram.com/developer/clients/manage/ 获得的client_id 和client_secret 值替换了YOUR_CLIENT_ID 和YOUR_CLIENT_SECRET 此外,正如文档所述,我为我的 access_token 增加了价值

Instagram API 需要来自经过身份验证的用户的 access_token 对于每个端点。我们不再支持仅使用 client_id。

接下来我尝试订阅一个标签(第 38-45 行)。 这会导致错误消息

OAuthParameterException occurred: Missing client_id or access_token URL parameter. in _request

尝试解决错误:

按照here 的建议,我在Instagram-node-lib/lib/class.instagram.js 中添加了以下代码行。这没有解决错误。

options['headers']['Content-Type'] = 'application/x-www-form-urlencoded';

我修改了Instagram-node-lib/lib/class.instagram.subscription.js 中的订阅功能,加入了verify_token。这也没有解决错误。

InstagramSubscriptions.prototype._subscribe = function(params) {
          var i, _i, _len, _ref;
          params['method'] = "POST";
          params['path'] = "/" + this.parent._api_version + "/subscriptions/";
          if ((typeof params['callback_url'] === 'undefined' || params['callback_url'] === null) && this.parent._config.callback_url !== null) {
            params['callback_url'] = this.parent._config.callback_url;
          }
          params['post_data'] = {
            object: params['object'],
            aspect: 'media',
            client_id: this.parent._config.client_id,
            client_secret: this.parent._config.client_secret,
            verify_token: this.parent._config.access_token,
            callback_url: params['callback_url']
          };
          _ref = ['object_id', 'verify_token', 'lat', 'lng', 'radius'];
          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
            i = _ref[_i];
            if (params[i] != null) {
              params['post_data'][i] = params[i];
            }
          }
          return this.parent._request(params);
        };

Instagram-node-lib 中的上述 2 个更改是使用

编译的
install npm --save https://github.com/zunman/instagram-node-lib/tarball/master

我的 package.json 以及 node、nom、instagram-node-lib 的更新版本如下。

{
  "name": "RealTimeInstagram",
  "version": "0.0.1",
  "description": "Real time instagram",
  "author": "Michael Lancaster",
  "dependencies": {
    "express": "3.21.2",
    "instagram-node-lib": "https://github.com/zunman/instagram-node-lib/tarball/master",
    "jade": "1.3.1",
    "request": "2.34.0",
    "socket.io": "1.7.4"
  },
  "engines": {
    "node": "6.9.1",
    "npm": "3.10.8"
  }
}

我不确定我错过了什么。非常感谢您对错误的任何帮助。

附: 我在this 项目中也遇到了同样的错误。

【问题讨论】:

    标签: javascript node.js instagram


    【解决方案1】:

    Instagram API 不再支持标签订阅: https://www.instagram.com/developer/changelog/

    在 2015 年 11 月 17 日或之后创建的应用

    • ...

    • 弃用标签、位置和地理位置的实时订阅

    不知道他们为什么这样做,但即使你摆脱了这个错误,你也不会收到标签更新。

    我正在尝试同样的事情,但以下行实际上对我有用(至少关于错误输出,因为我的应用程序没有收到任何通知):

    options['headers']['Content-Type'] = 'application/x-www-form-urlencoded';
    

    您可能可以使用“最近的媒体标签”端点 (https://www.instagram.com/developer/endpoints/tags/#get_tags_media_recent),在您的应用程序中使用计时器或其他东西并不时进行搜索。不是最好的世界,但应该可以。

    【讨论】:

    • 感谢您的回复。我会试试最近的媒体标签
    • 我仍然遇到同样的错误。但是,知道不推荐使用按标签、位置、地理位置进行实时订阅确实会有所帮助。我的用例涉及订阅地理。谢谢你的帮助@L。清水
    • 我明白了...尝试使用这个存储库(它是我使用的那个,与 header.content-type 行一起使用):link to git
    猜你喜欢
    • 2023-03-03
    • 1970-01-01
    • 2021-11-05
    • 2012-04-30
    • 1970-01-01
    • 1970-01-01
    • 2014-05-31
    • 2017-01-15
    • 2012-08-29
    相关资源
    最近更新 更多