我試圖將curl命令從instagram api轉換爲jquery(ajax/get)。乾淨的方法來將CURL轉換爲jQuery/Javascript [Instagram]
curl -F 'client_id=CLIENT_ID' \
-F 'client_secret=CLIENT_SECRET' \
-F 'grant_type=authorization_code' \
-F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \
-F 'code=CODE' \
https://api.instagram.com/oauth/access_token
從DOC:
「爲了使這種交換,你只需要一些app標識參數一起發佈此代碼, 」
var clientId = "my client id";
var clientSecret = "my client secret";
var redirectURI = "http://localhost:3000/instagram";
var myCode = "my instagram code";
var uri = 'https://api.instagram.com/oauth/access_token?client_id=' + clientId + '&client_secret=' + clientSecret + '&grant_type=authorization_code&redirect_uri=' + redirectURI + '&code=' + myCode;
var url = encodeURIComponent(uri);
$.ajax({
type: "POST",
dataType: "json",
url: ' https://api.instagram.com/oauth/access_token?client_id=' + clientId + '&client_secret=' + clientSecret + '&grant_type=authorization_code&redirect_uri=' + redirectURI + '&code=' + myCode,
success: function (result) {
console.log(result);
}
});
似乎並不爲我工作...
獲得跨源塊請求[CORS]錯誤。
您在瀏覽器控制檯有有趣的錯誤**似乎並不爲我工作** – madalinivascu
獲得跨源塊請求[CORS]錯誤^^ – teddym