Contact Us
Hire PHP Web Developer
$xml_url = "http://scriptforphp.blogspot.com/feeds/posts/default";
$ch = curl_init($xml_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
if(!preg_match("|The blog you were looking for was not found.|Ui",$data))
{
$xml = new SimpleXmlElement($data, LIBXML_NOCDATA);
$xml_detail = parseAtom($xml);
for($j=0; $j<count($xml_detail); $j++)
{
$url = addslashes($xml_detail[$j][url]);
$title = addslashes($xml_detail[$j][title]);
$desc = addslashes($xml_detail[$j][desc]);
}
}
function parseAtom($xml)
{
$cnt = count($xml->entry);
$atom = array();
for($i=0; $i<$cnt; $i++)
{
$total_link = count($xml->entry[$i]->link);
for($j=0; $j<$total_link; $j++)
{
$urlAtt = $xml->entry[$i]->link[$j]->attributes();
if($urlAtt['rel']=="alternate")
{
$atom[$i]['url'] = $urlAtt['href'];
}
}
$atom[$i]['title'] = $xml->entry[$i]->title;
$atom[$i]['desc'] = substr(strip_tags($xml->entry[$i]->content),0,130);
}
return $atom;
}