Posting at Blogger.com through Google scripts

211 views Asked by At

I have searched all over and even explored Google repositories however I couldn’t get this done; basically, I want to add new posts at my Blogger account using Google script editor.

var apikey = ‘myapikey’;
var opt = 
    {
        "method": "post",
        "muteHttpExceptions": true,
        "kind": "blogger#post",
        "blog":
            {
                "id": "6216388180804588185"
            },
        "isDraft": true,
        "title": "A new post",
        "content": "My first API based post!"
    }

try
{
    var results = UrlFetchApp.fetch("https://www.googleapis.com/blogger/v3/blogs/"+blogid+"/posts/?key="+apikey, JSON.stringify(opt));
    Logger.log(results);
} catch (exc)
{
    Logger.log(exc);
}

No matter what I do, it always shows error. Sometime it is authentication error and for the rest, it says "Bad value". I have enabled Blogger Api v3 from developer console and got a valid API key as well. Suggest me what I am doing wrong, I don't want to search more for the solution as I have done too much searching already.

0

There are 0 answers