113
94

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Google Apps ScriptからHTTP POST

Last updated at Posted at 2014-07-05

Google Driveのスプレットシートをハックしようと思って勉強してます。

ここのサンプルをもとに書いたらあっさりいけました。
Class UrlFetchApp - Google Apps Script — Google Developers -

##サンプルリクエスト例

curl http://example.com -X POST -d 'message=google apps scriptより'

##Google Apps Scriptで書くとこんな感じ

httppost.gs
/* 
* messageをpostする関数
*/
function sendHttpPost(message){
   var payload =
   {
     "message" : message
   };

   var options =
   {
     "method" : "post",
     "payload" : payload
   };

   UrlFetchApp.fetch("http://example.com", options);
}

function myFunction(){
  var message = 'google apps scriptより';
  sendHttpPost(message);
}

めちゃカンタンですね。

113
94
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
113
94

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?