【发布时间】: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