2011-01-19

Getting categories out of blogspot/blogger feeds

Previous post about coding was about syndicating images in PicasaWeb with JonDesign`s Javascript gallery which uses mootools. Next task was mixing blogspot/blogger feeds in standalone web page. And again using easyXML in PHP5 it is easy as pie. In this script the interesting part is learning what the "child" is. If there is one big main structure, where similar smaller structures are built in, then these structures are like children to this main one. And in blogspot/blogger feeds there are possible to get tags or categories for each post. Additionaly, the term of the category is as attribute name inside the feed`s tag. It`s necessary to use attributes()->term, where term is attribute which has different possible names. And as these attributes could be more than one in each post or entry, then there it is where child is born. A new, child simpleXML object is created within this entry, and, correctly parsing, it is possible to get multiple items in each post. "foreach" entry categories loop inside of "foreach" entries loop.
And here is code to see it how it looks like and another DEMO link how it works.

Thus it is possible to get new blogspot/blogger feeds which are based on given tag/category, when building the hyperlink just add "/-/$category_name" in the end of blogger/blogspot full feeds link.

by the way the full blogger/blogspot feeds link is
"http://blogspotuser.blogspot.com/feeds/posts/default"
And modified link should look like

http://blogspotuser.blogspot.com/feeds/posts/default/-/category

Nav komentāru:

Ierakstīt komentāru