问题描述
我已成功使用curl,如下所示:
curl -X GET -H"Authorization: sso-key [GoDaddy Key]:[GoDaddy Secret]" https://api.ote-godaddy.com/v1/domains/available?domain=example.guru
但是,从Google Apps脚本来看,我一直没有成功。我花了很多时间研究和尝试不同的东西,但没有任何工作对我有用。这是两个最相关的示例:
#1)使用Utilities.base64Encode
function myFunction() {
var apiUrl = 'https://api.ote-godaddy.com/v1/domains/available?domain=example.guru';
var apiKey = '[GoDaddy Key]';
var apiSecret = '[GoDaddy Secret]';
var myHeaders = {
'Accept': 'application/json','Authorization': 'sso-key ' + Utilities.base64Encode(apiKey + ':' + apiSecret),'muteHttpExceptions': true
};
var params = {
'headers' : myHeaders,'method' : 'GET','contentType' : 'application/json'
}
var reponse = UrlFetchApp.fetch(apiUrl,params);
var responseCode = response.getResponseCode();
}
结果:
Exception: Request Failed for https://api.ote-godaddy.com returned code 401. Truncated server response: {"code":"MALFORMED_CREDENTIALS","message":"Unauthorized : API Key-Secret is malformed"}
#2)不使用Utilities.base64Encode
function myFunction() {
var apiUrl = 'https://api.ote-godaddy.com/v1/domains/available?domain=example.guru';
var apiKey = '[GoDaddy Key]';
var apiSecret = '[GoDaddy Secret]';
var myHeaders = {
'Accept': 'application/json','Authorization': 'sso-key ' + apiKey + ':' + apiSecret,params);
var responseCode = response.getResponseCode();
}
结果:
没有回音。调用response is not defined
时出现getResponseCode()
错误。
有人成功通过Google Apps脚本调用GoDaddy API吗? 任何帮助将不胜感激!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)