卷曲命令:
curl -u "username:password" -X POST "https://api-ssl.bitly.com/oauth/access_token"
我尝试过:
$.ajax({
url: 'https://api-ssl.bitly.com/oauth/access_token',
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
type: "POST",
dataType: 'json',
contentType: 'application/x-www-form-urlencoded',
success: function (result) {
console.log(result);
},
error: function () {
alert("Cannot get data");
}
});
我尝试过使用dataType:jsonp,contentType:json和其他方法,但总是得到错误响应?我做错了什么?