UrlFetchApp wrapper https://github.com/oshliaer/fetch
-
-
Save oshliaer/d14d3f23e4b1e7cb7dba91f43b0addbe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createPost() { | |
| var content = DocumentApp.openById("1BVEqtuXPmDf3ruLKfeYlkSoDCrDkGLdJpLkHxGwoyqg").getBody().getText(); | |
| var options = { | |
| payload: { | |
| "kind": "blogger#post", | |
| "blog": { | |
| "id": "7091170028680816449" | |
| }, | |
| "title": "A new post", | |
| "content": content | |
| }, | |
| } | |
| var response = Fetch.post("https://www.googleapis.com/blogger/v3/blogs/7091170028680816449/posts", options); | |
| Logger.log(response.getContentText()) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getBlog() { | |
| var response = Fetch.get("https://www.googleapis.com/blogger/v3/blogs/7091170028680816449"); | |
| Logger.log(response.getContentText()) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function updatePost() { | |
| // var docExport = Drive.Files.get("1BVEqtuXPmDf3ruLKfeYlkSoDCrDkGLdJpLkHxGwoyqg").exportLinks["text/html"]; | |
| // var content = Fetch.get(docExport).getContentText(); | |
| var doc = DocumentApp.openById("1BVEqtuXPmDf3ruLKfeYlkSoDCrDkGLdJpLkHxGwoyqg"); | |
| var content = doc.getBody().getText(); | |
| var title = doc.getName(); | |
| var options = { | |
| payload: { | |
| "kind": "blogger#post", | |
| "id": "5780301629671909223", | |
| "blog": { | |
| "id": "7091170028680816449" | |
| }, | |
| "title": title, | |
| "content": content | |
| }, | |
| } | |
| var response = Fetch.put("https://www.googleapis.com/blogger/v3/blogs/7091170028680816449/posts/5780301629671909223", options); | |
| Logger.log(response.getContentText()) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment