javascript - How do I filter a Blogger feed by label? -
I used Google's Blogger API to retrieve items from my blogger blog to display on my home page I am I am using What I want to be able to do, the filter entries returned by the label I have done a lot of searches but, although it seems that it should be simple, I have not received any clear instructions.
To recover Blogger entries, my code looks like this: This gives everything on the blog How do I get it back to entries only, where I thought It will be answered by now, but it seems that there are dead who are now dead, so whatever information they had organized is now unavailable. Finally it found that it turns as much as I thought was as easy. I had to add this line of code to the request code I had to do: Some things that I had slipped out, that the area is labeled 'plural', 'label', singular. Also, for some reason, it seems that the 'label' specification must come before 'fetchBodies', or the code fails. I'm not sure why this will happen, but this was my experience. function init () {// http://code.google.com/apis/ Get your API key from 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 = gapi.client.blogger.posts.list ({'BlogId': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'fields': 'item (content, title, update, id, label)', 'fetchBodies': true}); request.execute (function) {var blogger = document .getElementById ("Blogger"); var for anchor = 0; (var i = 0; i & lt; response.items.length; i ++) {var bloggerDiv = document.createElement ("div"); bloggerDiv. Id = "Blogger -" + i; bloggerDiv.className = "bloggerItem"; // For some parts of the response, click on the result at http://code.google.com/apis/explorer/#_s=blogger& Enter;; _v = v2 and amp; _m = posts.list and blog id = xxxxxxxxxxxxx $ (blogger dev) .append ("& lt; h2>" + response.items [i] .title + "& lt; / H2 & gt; "); var date = response .items [i]. Updated; date = date. Rale (" t "," "); date = date.rele (" + 03:00 "," "); Var printDate = new moment (date); $ (BloggerDiv) .append (" & lt; P & gt; & Lt; Span class = 'bylin E' & gt; "+ PrintDate.format ('dddd, MMMM two YYYY, h: mm: ss a') +" & lt; / Span & gt; & Lt; / P & gt; "); $ (BloggerDiv) .append (response.items [i] .content); // This logic can be useful to keep around if I want to decide whether / is to do something different or not The last item // does not require a different formatting or if // (i + 1 & lt; response.items.length) {// $ (Blogger Dee) .append ("& lt; hr & gt; "); //} // $ (Blogger Dee) .append (" & lt; hr & gt; "); BloggerEncrekt = Document; createElement (" a "); BloggerAnchor.name =" blogger- "+ response.items [I] .id; blogger.appendChild (bloggerAnchor); blogger.appendChild (bloggerDiv); anchor = anchor + 1;} // know which user Anchor wanted ... var hashVal = window.location.hash.substr (1); // ... then go to that position: location.hash = "#" + hashwell;});});}
label = "XYZ" ?
var request = gapi.client Blogger.posts.list ({'blogId' : 'Xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'fields': 'item (content, title, update, id, label)', 'label': 'xyz', 'fetchBodies': true});
Comments
Post a Comment