In this series of posts, we will make an attempt to build a Digg widget for blogger. What difference would this widget make, when there are already plethora of Digg widgets available? Well, this widget would help to find "related posts" from Digg, with the labels specified against your post.
To make this widget, first let us make an attempt to build this widget in Java and later post a solution where we integrate this with Blogger. This would be approached on the same lines as we built the "Related Post" widget for Blogger earlier. To make a Digg related post widget for Blogger, we would do the following
1) Build a Java solution which can Query Digg and retrieve a bunch of posts as XMLs.
a) Standard HTTP Request based Approach
b) Using VTD
2) Use XSLT transformation to convert the result set from Digg into a set of hyperlinks.
3) Test the solution for some Keywords.
4) Extend the solution to achieve the same using JQuery and Integrate it with blogger.
5) Final code to make this workable with Blogger
6) Demo page that gives a live demo of this approach.
If you are purely here to get the widget, you can quickly jump to sections 5 and 6 from where you can get the code. If you would like to know something in Java, VTD, XSLT transformation etc, you can read through from here to see how the solution can be constructed. The reason for covering them is to enable a widget development in non-blogger platforms also.
But before we move any further, the basics for building this entire setup is a simple HTTP request to Digg to query the related post and display it in your blog. A sample HTTP request is provided below
The output from Digg can be obtained in the form of an XML. A XML is given below
So, the direction is set for us. HTTP request to be invoked, and the response XML from Digg needs to be processed, and a conversion needs to be applied to the response XML to get it as a hyperlinked text.
Here we go.
To make this widget, first let us make an attempt to build this widget in Java and later post a solution where we integrate this with Blogger. This would be approached on the same lines as we built the "Related Post" widget for Blogger earlier. To make a Digg related post widget for Blogger, we would do the following
1) Build a Java solution which can Query Digg and retrieve a bunch of posts as XMLs.
a) Standard HTTP Request based Approach
b) Using VTD
2) Use XSLT transformation to convert the result set from Digg into a set of hyperlinks.
3) Test the solution for some Keywords.
4) Extend the solution to achieve the same using JQuery and Integrate it with blogger.
5) Final code to make this workable with Blogger
6) Demo page that gives a live demo of this approach.
If you are purely here to get the widget, you can quickly jump to sections 5 and 6 from where you can get the code. If you would like to know something in Java, VTD, XSLT transformation etc, you can read through from here to see how the solution can be constructed. The reason for covering them is to enable a widget development in non-blogger platforms also.
But before we move any further, the basics for building this entire setup is a simple HTTP request to Digg to query the related post and display it in your blog. A sample HTTP request is provided below
http://services.digg.com/1.0/endpoint?method=search.stories&query=peoplesoft&topic=programming&count=5 This request retrieves five posts from Digg, by hitting a search query of 'PeopleSoft' and queries under the topic 'Programming'. |
The output from Digg can be obtained in the form of an XML. A XML is given below
<?xml version="1.0" encoding="UTF-8"?> <stories count="2" offset="0" timestamp="1 271491009" total="29" version="1.0"> <story link="http://www.oracle.com/applicati ons/peoplesoft/tools_tech/ent/ptools/application-development.html" submit_date=" 1269423261" diggs="1" id="20131750" comments="0" href="http://digg.com/programmi ng/PeopleTools_Application_Development_Applications_Oracle" status="upcoming" media="news"> <description>Peoplesoft</description> <title>PeopleTools Application D evelopment | Applications | Oracle</title> <user icon="" name="hari86av" profileviews="148" registered="1196363365"/> <topic name="Programming" short_name="progra mming"/> <container name="Technology" short_name="technology"/> <shorturl short_url="http://digg.com/d31MTBe" view_count="0"/> </story> <story link="http://www.aire d.in/2009/10/peoplesoft-admin-interview-questions.html" submit_date="1262492162" diggs="1" id="18226229" comments="0" href="http://digg.com/programming/PeopleSo ft_Administration_Interview_Questions_2" status="upcoming" media="news"> <description>Help prepare for an Peoplesoft Administrator Interview</description> <title> PeopleSoft Administration Interview Questions</title> <user icon="" name="datalin k4i" profileviews="307" registered="1160585515"/> <topic name="Programming" short_name="programming"/> <container name="Technology" short_name="technology"/> <shorturl short_url="http://digg.com/d31ETTR" view_count="25"/> </story> </stories> |
So, the direction is set for us. HTTP request to be invoked, and the response XML from Digg needs to be processed, and a conversion needs to be applied to the response XML to get it as a hyperlinked text.
Here we go.
No comments:
Post a Comment