Mio*_*ter 4 pastebin google-sheets google-apps-script google-apps-script-api
我正在尝试使用电子表格脚本编辑器中的Google Apps脚本粘贴Pastebin.com 。谁能告诉我我在做什么错?
function postPastebinPost() {
var options, url, apiKey, payload, response;
apiKey = <api key goes here>;
payload = 'Hello World';
options = {
'method' : 'post',
'payload' : payload
};
url = 'https://pastebin.com/api/api_post.php'
+ '?api_dev_key=' + apiKey
+ '&api_option=paste'
+ '&api_paste_code=' + encodeURIComponent(payload);
response = UrlFetchApp.fetch(url, options);
Logger.log(response);
}
Run Code Online (Sandbox Code Playgroud)
我运行此命令,日志显示为Bad API request, invalid api_option。我正在寻找解决方案,但没有找到任何解决方案。
说明文件:
•Google Apps脚本的UrlFetchApp类
参数应在POST请求的有效负载中传递。
function postPastebinPost() {
var apiKey = 'YOUR KEY GOES HERE';
var text = 'Hello World';
var payload = {
api_dev_key: apiKey,
api_option: 'paste',
api_paste_code: text
};
var options = {
method : 'POST',
payload: payload
};
var url = 'https://pastebin.com/api/api_post.php';
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getContentText());
}
Run Code Online (Sandbox Code Playgroud)