好的,所以我对coffeescript很新,并且无法弄清楚这里发生了什么。我使用instagram-node-lib构建了一个hubot脚本。完全跳过InstagramOAuth.prototype.ask_for_access_token
类完整方法。
robot.router.get '/hubot/feedbomb', (req, res) ->
Instagram.oauth.ask_for_access_token(
grant_type: 'authorization_code'
code: accounts[account].details.theCode
request: req
response: res
complete: (params, response) ->
user_acces_token = params['access_token']
response.writeHead(200, {'Content-Type': 'text/plain'})
res.end "Yup!"
error: (errorMessage, errorObject, caller, response) ->
console.log("Error on #{errorObject}: #{errorMessage}")
res.end "McNope"
)
我确定这是我不能正确理解的事情吗?
修改
我在instagram-node-lib中添加了ask_for_access_token方法,以防某些事情显而易见。我想也许点符号与文字符号?
InstagramOAuth.prototype.ask_for_access_token = function(params) {
var parsed_query, token_params, url;
url = require('url');
parsed_query = url.parse(params['request'].url, true).query;
if (parsed_query.error != null) {
return this.parent._error("" + parsed_query.error + ": " + parsed_query.error_reason + ": " + parsed_query.error_description, parsed_query, 'handshake');
} else if (parsed_query.code != null) {
token_params = {
complete: params['complete'],
response: params['response'],
method: "POST",
path: "/oauth/access_token",
post_data: {
client_id: this.parent._config.client_id,
client_secret: this.parent._config.client_secret,
grant_type: 'authorization_code',
redirect_uri: params['redirect_uri'] === void 0 || params['redirect_uri'] === null ? this.parent._config.redirect_uri : params['redirect_uri'],
code: parsed_query.code
}
};
this.parent._request(token_params);
if (params['redirect'] != null) {
params['response'].redirect(params['redirect']);
return params['response'].end();
}
}
};