Retrieve Content Excerpt From Blogger JSON Feed API |
Retrieve Content Excerpt From Blogger JSON Feed API Posted: 29 Oct 2015 08:33 AM PDT We have received some great feedback from all of you since the day we started this step-by-step tutorial series on extracting data from Blogger JSON Data API. So far we have discussed the basics of extracting data from a JSON file and we succeeded in developing a recent Posts widget sorted by Label. Today we will learn how to extract excerpt of your Posts. You will be able to extract the first few characters from the starting paragraph of your blog posts that are located above the "Jump break" or you can also extract all the post content and print it. We normally retrieve Content summary and display first few lines inside the recent posts widget to give an idea of what the post is all about. It is sort of a brief description of the article itself. You might have seen the description snippet appearing below recent posts in Wordpress blogs and today you will learn how to code your blogspot widget to display Post summary of your recent articles published on your blog. Lets get to work, same code but with slight modifications! Note: Click the Button below to see full list of topics under discussion. Topics List Where is the Content Data Stored?As we discussed in our last tutorial, you first need to change your site feed settings to allow feed in "Full" length or you can also choose "Until Jump break", only then you can you proceed. Your post content is stored as HTML inside the following path:
Which means we will first search through [ ] entry array and then extract the post html data from the { } content object where the content is stored inside the node $t as shown below: Click the content node and you will see that the $t stores your entire post as its value. Displaying Recent Posts by Label in BloggerWe will use the exact same code that we shared in Part#6 , the only addition that we made this have been highlighted as Green.Note:
OUTPUT You have now created a recent posts width that displays Titles with Post Summaries or Post excerpts. Have Questions?Confused with any part still un-cleared just post your comments. In my next tutorial I will share how to display thumbnails next to each title. We will also learn how to display YouTube thumbnails and other third party thumbnail images inside this widget. A lot is on its way so stay tuned for all the updates! Can you answer why we used substr() and not substring() method here? :) Peace and blessings buddies! :> |
Site Feed Settings - Choose 'Full' or 'Short'? Posted: 28 Oct 2015 11:34 AM PDT Before proceeding towards extracting description snippet or summary snippet from JSON feed, it is really important to first understand what does the Blogspot Site feed tool for feed syndication actually do. Site feed setting options effect how your Feed structure is built and displayed and what data is contained inside the { } summary or { } content objects. Your JSON feed extraction will seriously fail if you have not chosen the right Feed length option. Lets explore this basic setting with technical perspective discussed first time online for blogspot blogs. Note: Click the Button below to see full list of topics under discussion. Topics List Site Feed Settings for BloggerYou clearly now that if you navigate to Blogger > Settings > Other > Site feed , you will land on a page where you can decide to enable or disable the site feed(s) for your blog. Here, you can select how much of your content you want to syndicate. 1 "Full" Selecting this option will put the entire content of each post in your site feed. This option creates a { } content object node in your JSON file. This node will store all content HTML (i.e. All media: Images, text, links, videos, post formatting etc.) of your post inside it. If you click this node, you will be able to see your article in exact same article because the HTML is stored here. This is the most important JSON node which holds the content of your entire article. The type of data stored in this node is "html" which means all your post formatting is maintained. 2 "Until Jump Break" This option shows all post content before your 'jump break' / 'read more'. Also creates a { } content object node but will store only content before the jump break. 3 "Short" Select Short to syndicate approximately the first 400 characters. This will only include an excerpt from the beginning of each post. Creates a { } summary object node in JSON Note that the type of data stored in this node is "text", which means you can now extract only plain text form this node but no content with thumbnail images, links or proper formatting. Therefore due to this reason throughout our tutorial series we will choose the "Full" option to display feeds in full length. 4 "None" It will turn off your site feed which no sane man would ever do! No JSON, atom or RSS XML files are generated for the blog If you select None, your blog will not be syndicated and its content will not be indexed by Google Blog Search! 5 "Custom" For more advanced options, you can select "Custom." Using this option you can choose Feed length for Posts and Comments separately. When you select "Custom," you'll see options for three different types of feeds. Each option has the same "Full," "Short," and "None" setting choices.
So far I don't see an exception usage of the "custom" option so we will avoid using it because the "Full" option provides us with all data that we need in clean and neat HTML formatting! Which Option to Choose?Throughout our tutorial we will display feeds in "Full" or "Until Jump Break" because both these options provide us with information that we need. You can choose anyone of them. If you think you don't wish to show full posts to your Email Subscribers then "Until Jump Break" option is what you need to choose. Have Questions?I hope you now know exactly what these site feed settings actually do at the technical side and how it effects the JSON structure of your feeds. Let me know if you need any help. The coming tutorials are extremely interesting and full of knowledge. Stay tuned! Peace and blessings buddies :> |
You are subscribed to email updates from My Blogger Tricks. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
0 comments:
Post a Comment