0
我一直在使用Google Apps腳本一段時間,但一些人總是掛在這個有效載荷的東西上。我只是想對mashape做一個基本的API調用。由於這是一個post調用,我很確定我應該在參數選項中使用有效載荷,但只是不確定是什麼把我的錯誤拋給了我。這裏是我的代碼:使用Google Apps腳本的Mashape API出現問題
function mashapeTextSentiment(text){
var key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var url = "https://japerk-text-processing.p.mashape.com/sentiment/";
var language = "english";
var payload = {
"X-Mashape-Key": key,
"language": language,
"text": text
};
var options = {
"method": "post",
"payload": payload
};
var response = UrlFetchApp.fetch(url, options);
var rs = JSON.parse(response.getContentText());
return rs;
}
function testMashapeTextSentiment(){
Logger.log(mashapeTextSentiment("Someone please help me with this!"));
}
這是它給我的錯誤:
Request failed for https://japerk-text-processing.p.mashape.com/sentiment/ returned code 401. Truncated server response: {"message":"Invalid Mashape application key provided"} (use muteHttpExceptions option to examine full response) (line 17, file "Code")
就像一個魅力!非常感謝 – mikemccarthys