I am using Javascript code made available by Brett Morgan to retreive posts
from my Blogger blog.
I think what I want to do is simple, but after a lot of searching, I can't
seem to get a clear answer. I just want to filter the posts by a label, so
that I only download posts where 'label = XYZ'.
How can I do that, using the following code?
Thank you for any help.
function init() {
// Get your API key from http://code.google.com/apis/console
gapi.client.setApiKey('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
// 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': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'fields': 'items(content,title,updated,id,labels)',
'fetchBodies': true
});
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";
// For the parts of the response, have a look at the result
at:
//
http://code.google.com/apis/explorer/#_s=blogger&_v=v2&_m=posts.list&blogId=xxxxxxxxxxxxx
$(bloggerDiv).append("<h2>" + response.items[i].title +
"</h2>");
var date = response.items[i].updated;
date = date.replace("T", " ");
date = date.replace("+03: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);
// This logic might be useful to keep around if I decide to do
// something different based on whether or not the last item
// needs different formatting in some way.
// if (i+1<response.items.length) {
// $(bloggerDiv).append("<hr>");
// }
// $(bloggerDiv).append("<hr>");
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;
});
});
}
--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/bloggerdev.
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.