Google Groups

Re: [bloggerDev] Re: JSON API V2 Example not working for newly created blog?


David Fisco May 9, 2012 8:52 PM
Posted in group: Blogger Developer Group
Has there been any progress with this?  I'm running into the same 404 Not Found error trying to make an authenticated request using the gapi approach.

On Wednesday, February 15, 2012 5:39:08 PM UTC-5, Brett Morgan wrote:
Ahh, thanks for explaining that Ruizzie. I suspect it's the result of something I mis-configured. I'll get this fixed soon.

In the mean time stay with the working version. I'll update this thread when it's fixed.

brett

On Thu, Feb 16, 2012 at 3:52 AM, Ruizzie <rui...@gmail.com> wrote:
Hi Brett,

Sorry for not being clearer before. I was following your example from
the 5th of januari:
Blogentry:
http://code.blogger.com/2012/01/easier-to-use-interface-for-blogger.html.


function init() {
 // Get your API key from http://code.google.com/apis/console


 // gapi.client.setApiKey(   "YOUR API KEY HERE";

 // Load the Blogger JSON API
 gapi.client.load('blogger', 'v2', function() {
   // Load the list of posts for code.blogger.com
   var request = gapi.client.blogger.posts.list({
     'blogId': 2795020174286211586,
     'fields': 'items(content,title)'
   });

   request.execute(function(response) {

     for (var i = 0; i < response.items.length; i++) {
       // 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=3213900
       $("#main").append("<h2>" + response.items[i].title + "</h2>");
       $("#main").append(response.items[i].content);
       if (i+1<response.items.length) {
         $("#main").append("<hr>");
       }
     }
   });
 });
}

which I can't get to work.

However, the sample from 8 september 2011,
Blogentry: http://code.blogger.com/2011/09/blogger-json-api-now-available.html

works like a charm:

 var apikey = "YOUR API KEY HERE";

 // You can find the blogId in the HTML source of a blog
 var blogId = "2795020174286211586";

 // When the document is loaded
 $(document).ready(function() {

   // Make a JSONP request for the Posts on the Blogger Buzz blog
   $.ajax({
     url:"https://www.googleapis.com/blogger/v2/blogs/”+
       blogId+”/posts?key="+apikey,
     dataType: "jsonp",
     success: function(data, textStatus, jqXHR) {
       var items = [];
       // Construct a chunk of HTML for each post
       // containing the Post title, content, and a
       // link to the post author.
       $.each(data.items, function(index, value) {
         items.push("<h2>"+value.title+"</h2>"+value.content+
           "<p>Posted by <em><a href='"+value.author.url+"'>"+
           value.author.displayName+"</a></em></p>");
       });

       // And finally, append the generated content to the page body.
       $(items.join('')).appendTo('body');
     }
   });
 });


The first example ends with a 404 'Not Found' error.
As the second example does work, this seems to point to the client
library?
I did actuaaly try any debugging of that yet... (short on time for
this project :-( ).

Regards,
Ries









On 15 feb, 09:54, Brett Morgan <brettmor...@google.com> wrote:
> On Wed, Feb 15, 2012 at 7:36 PM, Ruizzie <ruiz...@gmail.com> wrote:
> > Hi Brett,
>
> > Thanks for the quick reply. I can request the blog using curl only
> > using the --insecure option. (I always have the greatest trouble
> > getting curl to do HTTPS..)
>
> That needs fixing, but it shouldn't selectively impact results based on
> argument values.
>
>
>
>
>
>
>
>
>
>
>
> > If I use:
>
> > curl "https://www.googleapis.com/blogger/v2/blogs/2795020174286211586/
> > posts?pp=1&key=AIzaSyBCo-Huml8EAujvzPCEkrxmgfe98mmIY6A" --insecure
>
> > I get the wanted response:
>
> > {
> >  "kind": "blogger#postList",
> >  "nextPageToken": "CgkIChjgsf7g1yYQgpSFo6OB-uQm",
> >  "prevPageToken": "CgkIChDhsf7g1yYQgpSFo6OB-uQm",
> >  "items": [
> >  {
> >   "kind": "blogger#post",
> >   "id": "7810509606849336452",
> >   "blog": {
> >    "id": "2795020174286211586"
> >   },
>
> > etc.  etc.
>
> > Using the blogger API still returns a "Not Found" message and a 404
> > code.
>
> Can you please define what you mean by "Using the blogger API"? All said
> and done, the above curl call is using the Blogger JSON API, albeit without
> the comfort of one of the client libraries to wrap up the details.
>
> I'm guessing you are using one of the client libraries. Which one?
>
>
>
>
>
>
>
>
>
>
>
> > As far as I know the blog is completely public..
>
> > Thanks again for your support.
>
> > Best regards,
> > Ries Spruit
>
> > On 15 feb, 01:07, Brett Morgan <brettmor...@google.com> wrote:
> > > Hi Ruizzie,
>
> > > Can you do the following for me?
>
> > > 1) Confirm that you have curl installed, and if not install it
> > fromhttp://curl.haxx.se/
> > > 2) Run the following commend from the commend line:
>
> > > $ curl "
> >https://www.googleapis.com/blogger/v2/blogs/2795020174286211586/posts...
> > > "
>
> > > brett
>
> > > On Wed, Feb 15, 2012 at 7:58 AM, Ruizzie <ruiz...@gmail.com> wrote:
> > > > Hello Brett,
>
> > > > I am trying to use your example code to incorporate a blog into our
> > > > site.
>
> > > > However..
>
> > > > -- Getting your blog (3213900) with my API key works
> > > > -- Getting my blog (2795020174286211586) results in a 'Not Found' 404
> > > > error.
>
> > > > Yet when I try the API explorer for this blog, there is no problem at
> > > > all.
>
> > > >http://code.google.com/apis/explorer/#_s=blogger&_v=v2&_m=posts.list&.
> > ..
>
> > > > Could the difference between 'blogger.com' and 'blogspot.com' (where
> > > > my new blog ended up) have anything to do with it?
>
> > > > Any advice is greatly appreciated!
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Blogger Developer Group" group.
> > > > To post to this group, send email to blogg...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > bloggerdev+...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/bloggerdev?hl=en.
>
> > > --
>
> > > Brett Morgan
>
> > > Developer Relations Engineer, Blogger
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Blogger Developer Group" group.
> > To post to this group, send email to blogg...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > bloggerdev+...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/bloggerdev?hl=en.
>
> --
>
> Brett Morgan
>
> Developer Relations Engineer, Blogger

--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To post to this group, send email to blogg...@googlegroups.com.
To unsubscribe from this group, send email to bloggerdev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bloggerdev?hl=en.




--

Brett Morgan

Developer Relations Engineer, Blogger