Questioner
Questioner

Reputation: 7463

Why am I suddenly not getting content from the Blogger API?

I have been using the Google API to get JSON data from my Blogger account and display and format blog posts on my own webiste.

It was working perfectly for weeks, and then suddenly, as of yesterday, the content stops displaying. The title, update (the date the post was updated), and the id, all come back just as they always have. Only the content stopped coming back.

I haven't changed the code in any way since first implementing it, and I looked for documentation to see if the API had changed, but didn't come across anything. So I am completely stumped as to why this one aspect of the code would suddenly stop working.

This is pretty much the entire Javascript that I use to get the JSON data. Is there something wroing with it?

function init() {
    // Get your API key from http://code.google.com/apis/console
    gapi.client.setApiKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    // Load the Blogger JSON API
    gapi.client.load('blogger', 'v3', function() {
        // Load the list of posts for code.blogger.com
        var request = gapi.client.blogger.posts.list({
            'blogId': 'xxxxxxxxxxxxxxxxxxx',
            'fields': 'items(content,title,updated,id)'
        });
        request.execute(function(response) {
            var blogger = document.getElementById("blogger");
            var anchor = 0;
            for (var i = 0; i < response.items.length; i++)
            {
                var bloggerDiv = document.createElement("div");
                bloggerDiv.id = "blogger-" + i;
                bloggerDiv.className = "bloggerItem";
                $(bloggerDiv).append("<h2>" + response.items[i].title + "</h2>");
                var date = response.items[i].updated;
                date = date.replace("T", " ");
                date = date.replace("+09:00", "");
                var printDate = new moment(date);
                $(bloggerDiv).append("<p><span class='byline'>" + printDate.format('dddd, MMMM Do YYYY, h:mm:ss a') + "</span></p>");
                $(bloggerDiv).append(response.items[i].content)
                bloggerAnchor = document.createElement("a");
                bloggerAnchor.name = "blogger-" + response.items[i].id;
                blogger.appendChild(bloggerAnchor);
                blogger.appendChild(bloggerDiv);
                anchor = anchor + 1;
            }
            // find out which anchor the user wanted...
            var hashVal = window.location.hash.substr(1);
// ... then jump to that position:
            location.hash = "#" + hashVal;
        });
    });
}

Upvotes: 0

Views: 239

Answers (1)

Giovanni Guarino
Giovanni Guarino

Reputation: 356

Now fetchBodies defaults is false instead of true. For this reason you need to add param fetchBodies=true.

Upvotes: 3

Related Questions