我想將我的應用程序連接到foursquare,並且我想在用戶登錄到某些地方時顯示一條消息。我試圖使用他們的實時api https://developer.foursquare.com/overview/realtimeFoursquare簽入回覆
一切工作正常,直到最後,(當我必須發送回覆帖子請求https://developer.foursquare.com/docs/checkins/reply)我使用express和node.js.這是我的發佈請求的樣子。
app.post('/handlepush', function(req, res) {
var checkin_id =req.param('checkin');
console.log(checkin_id);
var obj = JSON.parse(checkin_id);
var id = obj.id;
res.end('It worked!');
var token = "********************************";
var post_data = querystring.stringify({text : "awesome"});
var options = {
host: 'api.foursquare.com',
path: '/v2/checkins/' + id + '/reply?oauth_token=' + token,
port: 443,
method: 'POST'
};
var req2 = https.request(options, function(res2) {
res2.setEncoding('utf8');
res2.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
req2.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
});
req2.write(post_data);
req2.end();
});
這是我的錯誤,由於某種原因,我不能添加參數爲我的帖子: BODY:{「元」:{「代碼」:400,「錯誤類型」:「其他」 ,「errorDetail」:「必須提供參數文本」},「response」:{}}
任何人都可以提供一個示例API調用,如果我的問題? – 2013-03-07 05:16:16