我正在尝试按照此文档使用ajax调用登录tinder:
https://gist.github.com/rtt/10403467
此处有以下表格:请求标题
和登录链接是:> curl -X POST https://api.gotinder.com/auth --data '{"facebook_token": fb_token, "facebook_id": fb_user_id}
'
我唯一的愿望是使用此方法成功登录:
这是我尝试过的: -
$("#btnSend").click(function () {
var dataUrl = "https://api.gotinder.com/auth";
var fbtoken = "[i wrote correct fb token here]";
var fbId = "[i wrote correct fb id here]";
var datavalue = '{"facebook_token": "' + fbtoken + '", "facebook_id": "' + fbId + '"}';
jQuery.ajax({
async: false,
type: "POST",
beforeSend: function (request) {
//request.setRequestHeader("X-Auth-Token",)
request.setRequestHeader("Accept-Language", "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5");
request.setRequestHeader("Accept", "*/*");
request.setRequestHeader("UserAgent", "Tinder/3.0.2 (iPhone; iOS 7.1; Scale/2.00)");
request.setRequestHeader("Accept-Encoding", "gzip, deflate");
},
headers: {"UserAgent": "Tinder/3.0.2 (iPhone; iOS 7.1; Scale/2.00)"},
contentType: "application/json",
dataType: "json",
data: datavalue,
url: dataUrl,
success: function (data) {
console.dir(data);
},
error: function (msg) {
}
});
});
请您帮忙在请求中设置正确的标头?
答案 0 :(得分:0)
$.ajaxSetup({
headers: { 'x-my-custom-header': 'some value' }
});
// Sends your custom header
$.ajax({ url: 'foo/bar' });
// Overwrites the default header with a new header
$.ajax({ url: 'foo/bar', headers: { 'x-some-other-header': 'some value' } });