AppsScript:測試並自我Query的方法
下面填入你的網址就能query了
var test_url = {你的測試網址};
var param_obj = {
'm': 123456,
};
function json2urlparams_(json) {
return Object.keys(json).map(
function(key) {
return encodeURIComponent(key) + '=' +
encodeURIComponent(json[key]);
}).join('&');
}
function test_post() {
var resp = UrlFetchApp.fetch(test_url, {
'method' : 'post',
'payload' : json2urlparams_(param_obj)
});
Logger.log('status:', resp.getResponseCode());
Logger.log('response:', resp.getContentText());
}
function test_get() {
var url = test_url + '?' + json2urlparams_(param_obj);
var resp = UrlFetchApp.fetch(url);
Logger.log('status:', resp.getResponseCode());
Logger.log('response:', resp.getContentText());
}
留言