處分配無效的左側嘗試完成OAuth2流,但繼續獲取未捕獲的引用錯誤。對Node.js來說是相當新穎的東西,似乎無法找出發生了什麼。ReferenceError:在對象
// require the blockspring package.
var blockspring = require('blockspring');
var request = require('request');
// pass your function into blockspring.define. tells blockspring what function to run.
blockspring.define(function(request, response) {
// retrieve input parameters and assign to variables for convenience.
var buffer_clientid = request.params["buffer_clientid"];
var buffer_secret = request.params["buffer_secret"];
var redirectURI = request.params["redirectURI"];
var tokencode = request.params["tokencode"];
request({
method: "POST",
url: "https://api.bufferapp.com/1/oauth2/token.json",
headers: {
'User-Agent': 'request',
},
body: client_id=buffer_clientid&client_secret=buffer_secret&redirect_uri=redirectURI&code=tokencode&grant_type=authorization_code
}, function(error, response, body){
console.log(body);
// return the output.
response.end();
});
});
你需要把你的左右'body'數據報價。 'client_id = buffer ...'應該是一個字符串。您正在嘗試將某些內容分配給不存在的'client_id'。 –
請求對象中的主體鍵需要格式化爲一個字符串。你或者需要用''string'+ variable +'string''來連接 – FrankerZ