Thumbnail of Blogger Post URL using Blogger API
Asked Answered
S

3

6

I have an app that uses Blogger API to show the posts of a blog in a listview. Is there a way in which I can extract the thumbnail of the corresponding post URL? This is general JSON response we get-

{


"kind": "blogger#blog",
      "id": "2399953",
      "name": "Blogger Buzz",
      "description": "The Official Buzz from Blogger at Google",
      "published": "2007-04-23T22:17:29.261Z",
      "updated": "2011-08-02T06:01:15.941Z",
      "url": "http://buzz.blogger.com/",
      "selfLink": "https://www.googleapis.com/blogger/v3/blogs/2399953",
      "posts": {
        "totalItems": 494,
        "selfLink": "https://www.googleapis.com/blogger/v3/blogs/2399953/posts"
      },
      "pages": {
        "totalItems": 2,
        "selfLink": "https://www.googleapis.com/blogger/v3/blogs/2399953/pages"
      },
      "locale": {
        "language": "en",
        "country": "",
        "variant": ""
      }
    }
Specious answered 5/3, 2017 at 14:15 Comment(0)
B
6

According to the documentation, If you query the endpoint for post list via -

https://www.googleapis.com/blogger/v3/blogs/blogId/posts

It should return a Post resource, from which you can access the images property to get the image URL for the individual posts.

But, currently the Blogger API doesn't return the images property when you call the post list or even the individual post endpoint (via - https://www.googleapis.com/blogger/v3/blogs/blogId/posts/postId). Therefore, you have two alternatives available -

  1. Either parse the HTML from the content property and find the Image URL from there.

  2. Or query the publicly available API for post list (via - https://www.blogger.com/feeds/blogID/posts/default?alt=json and get the image URL via the media$thumbnail property)

Baccy answered 5/3, 2017 at 20:42 Comment(2)
Will try that!!Specious
add a parameter to the query string fetchImages=trueListon
G
1

In case you're using Google API Client for Java to access the Blogger API v3, you'll have to set true to the fetchImages boolean property of the Blogger.Posts.List object:

// the request action
final Blogger.Posts.List postsListAction = blogger.posts().list(BLOG_ID);

// get post images as well (default: false)
postsListAction.setFetchImages(true);
Garlaand answered 8/8, 2020 at 12:42 Comment(0)
N
1

Try following 2 parameters for list page.

 fetchBodies=false
 fetchImages=true

I wish they had also added an overview flag in request, Something which decide to return few line of readable content from post.
Right now whole markup is returned.

if you want to show post overview also along with image and title then you need to manipulate the content value by javascript to extract first few line of readable content.

Noto answered 20/4, 2022 at 7:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.