Since Google's feed load service was turned off, I'm struggling to find a new way to display xml feeds across different protocols and domains. I need to feed in a blog onto a website. The website is https, the blog is not. I have a some success here, but only in getting the title. I need to wrap the title in the link, and insert it into a li. Got that working, need to get it into DOM
Here is my proxy the path is (/SSI/Processor/feedProxy.php):
<?php
function download_page($path){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$path);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$retValue = curl_exec($ch);
curl_close($ch);
return $retValue;
}
$sXML = download_page('https://www.external.com/feeds/feed.xml');
$oXML = new SimpleXMLElement($sXML);
$items = $oXML->entry;
$i = 0;
foreach($items as $item) {
$title = $item->title;
$link = $item->link;
echo '<li>';
foreach($link as $links) {
$loc = $links['href'];
echo "<a href=\"$loc\">";
}
echo $title;
echo "</a>";;
echo "</li>";
if(++$i == 3) break;
}
?>
Edit
I can now get all the xml returned, and formatted via PHP. I just can't insert it into DOM with jQuery!
And my jQuery:
$(function(){
$.ajax({
type: "GET",
url:'/SSI/Processor/feedProxy.php',
dataType: "html",
success: function(html) {
console.log(html);
//console log is showing the formatted HTML
$('#feeds').html(html);
});
});
I am struggling with how to parse it in PHP. It needs to output like this: <li><a href="linkfromxml">link text</a></li> and append that to a div.