Date: 05/09/05 (PHP Community) Keywords: rss, xml, web [Error: Irreparable invalid markup ('') in entry. Owner must fix manually. Raw contents below.] I wrote a code for Fetching LJ content of a community. Am using RSS here. I wrote one XML Parser, It displays the entries in proper format (User can modify the code for his/her choicable format). It also displays the user name and userpic of the person who posted the entry in the community, also it counts the number of comments for that post and displays the comment count. Also it displays the current music, current mood and the mood icon used for that entry. This code will be helpful when someone is designing a website for a community and wants to fetch the LJ contents in the site... I've not yet tested the code for all types of design. If anyone can test the code and find the errors and fix them, it'll be helpful for everyone... // +----------------------------------------------------------------------+ // | CommunityLJcatch version 1.1 | // +----------------------------------------------------------------------+ // | This program is free software; you can redistribute it and/or | // | modify it under the terms of the GNU General Public License | // | as published by the Free Software Foundation; either version 2 | // | of the License, or (at your option) any later version. | // | | // | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | // | 02111-1307, USA. | // | | // +----------------------------------------------------------------------+ // | Author: Sutanu Mandal // | Website: http://www.wearesphinx.net | // +----------------------------------------------------------------------+ // | File: fetch.php | // | Description: Contains php code and XML parser to fetch | // | Livejournal Entries from Community LJ Page | // | Last Update: 22/04/2005 | // +----------------------------------------------------------------------+ // Basic Requirements $community="wearesphinx"; // Mention your community name here $backend = "http://www.livejournal.com/community/".$community."/data/rss/"; // End // variables needed later $insideitem = false; $tag = ""; $title = ""; $description = ""; $link = ""; $mood = ""; $music = ""; $comment = ""; $datetime = ""; // end function startElement($parser, $tagName, $attrs) { // The function used when an element is encountered global $insideitem, $tag; if ($insideitem) { $tag = $tagName; } elseif ($tagName == "ITEM") { $insideitem = true; } } function characterData($parser, $data) { // The function used to parse all other data than tags global $insideitem, $tag, $title, $description, $link, $mood, $music, $comment, $datetime; if ($insideitem) { switch ($tag) { case "TITLE": $title .= $data; break; case "DESCRIPTION": $description .= $data; break; case "LINK": $link .= $data; break; case "COMMENTS": $comment .= $data; break; case "LJ:MUSIC": $music .= $data; break; case "LJ:MOOD": $mood .= $data; break; case "PUBDATE": $datetime .= $data; break; } } } function endElement($parser, $tagName) { // This function is used when an end-tag is encountered. global $insideitem, $tag, $title, $description, $link, $mood, $music, $comment, $datetime, $community; if ($tagName == "ITEM") { /*Code for finding the entry ID*/ $linkid=preg_split('[/]',trim($link)); $entryfile=$linkid[count($linkid)-1]; list($entryname,$dummy)=split('[\.]',$entryfile); // Find the Date and time of Post $datearray=preg_split('[ ]',$datetime); if(empty($title)) { $title="Nothing to say Baby"; } printf(" %s", // make our title into an actual linkhtmlspecialchars(trim($title))); // remove html characters from the title //-------------------------------------------------------------------- // Find out the user who made the post print " "; $ljfile="http://www.livejournal.com/community/".$community."/".$entryname.".html"; $content=file_get_contents($ljfile); chop($content); $val=strstr($content,"
antivirus |
apache |
asp |
blogging |
browser |
bugtracking |
cms |
crm |
css |
database |
ebay |
ecommerce |
google |
hosting |
html |
java |
jsp |
linux |
microsoft |
mysql |
offshore |
offshoring |
oscommerce |
php |
postgresql |
programming |
rss |
security |
seo |
shopping |
software |
spam |
spyware |
sql |
technology |
templates |
tracker |
virus |
web |
xml |
yahoo |
home
|