basically as the tittle says, i have got an API feed in PHP and im currently showing it in an iframe across the site, yes i know its not best practice, im now looking to get rid of the iframes due to some people not been able to see it and slows the page load. Thank you
jQuery or AJAX will do this. If you're familiar with jQuery, it is only 2 or 3 lines to set it up to fill a div with whatever information you want. If jQuery isn't your thing, it can be done with AJAX in about 20 lines.
Hi i will have a look into it, this is basically the php that i then show on site by iframe as a banner. PHP Code: <? $affiliateid = '........'; //Letters and numbers $trackingid = '.........'; //numbers only function UrlSigner($urlDomain, $urlPath, $partner, $key){ settype($urlDomain, 'String'); settype($urlPath, 'String'); settype($partner, 'String'); settype($key, 'String'); $URL_sig = "hash"; $URL_ts = "timestamp"; $URL_partner = "aid"; $URLreturn = ""; $URLtmp = ""; $s = ""; $time = time(); $urlPath = str_replace(" ", "+", $urlPath); $URLtmp = $urlPath . "&" . $URL_partner . "=" . $partner . "&" . $URL_ts . "=" . $time; $s = $urlPath . "&" . $URL_partner . "=" . $partner . "&" . $URL_ts . "=" . $time . $key; $tokken = ""; $tokken = base64_encode(pack('H*', md5($s))); $tokken = str_replace(array("+", "/", "="), array(".", "_", "-"), $tokken); $URLreturn = $urlDomain . $URLtmp . "&" . $URL_sig . "=" . $tokken; return $URLreturn; } $request = simplexml_load_file(UrlSigner('http://uk.shoppingapis.kelkoo.com', '/V2/productSearch?query=ipod&show_products=1&show_subcategories=0&show_refinements=0&logicalType=and&start=1&results=6&merchantId=', $trackingid, $affiliateid)); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Kelkoo iPod Banner Example</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } --> </style></head> <body> <table width="960" border="1" cellpadding="5"><tr> <? foreach ($request->Products->Product as $details) { $ProductName = $details->Offer->ProductName; $GridImage = $details->Offer->GridImage->Url; $Price = $details->Offer->Price; $Url = $details->Offer->Url; echo '<td width="160" valign="top" style="border:0;"><a href="'.$Url.'"><img src="'.$GridImage.'" style="float:left;border:0; margin-right:1px;" alt="'.$ProductName.'" title="'.$ProductName.'" height="90" width="90"/></a>'.$ProductName.'<br /><span style="color:#FF0000; font-weight:bold;">£'.$Price.'</span></td>'; } //echo '<pre>'; //print_r($request); //echo '</pre>'; ?></tr></table> </body> </html> Code (markup):
Implementing it with jquery is easier than you think. step 1: download and install jquery simply download the jquery file upload it to your server and include the js file in your <head> step 2: change your php file Delete all html from your php file except the <table> step 3: create an area where you want to display the rss feed in easiest would be a div and give it an id <div id="rssresults"></div> HTML: step4: load the file use this javascript code $(window).load(function () { $('rssresults').load('PLACE URL TO YOUR PHP FILE HERE'); }); Code (markup): Step5: enjoy That is if I done everything correct
i have got it to work by removing the doc type, html, head, body, and placing the rest of code in the page with a few tweaks, this works for 2 of my areas/sub domain but sadly not on another that uses smarty.
i have it on a test page test.adooz.co.uk (not validated tho) but this and my other area that its on dont use smarty, as far as i know now its the way smarty has been set up, replace with {php} will not work because i need to upgrade, so for now that area will stay the same.