Skip to content

Instantly share code, notes, and snippets.

@oshliaer
Last active December 4, 2018 04:51
Show Gist options
  • Save oshliaer/d14d3f23e4b1e7cb7dba91f43b0addbe to your computer and use it in GitHub Desktop.
Save oshliaer/d14d3f23e4b1e7cb7dba91f43b0addbe to your computer and use it in GitHub Desktop.
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())
}
function getBlog() {
var response = Fetch.get("https://www.googleapis.com/blogger/v3/blogs/7091170028680816449");
Logger.log(response.getContentText())
}
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