Niche Designer

An Exploration of Niche Site Design and Development
Jan
26

PeakClick + Dreamhost = SimpleXML

Category Niche Marketing  Time  9:00 pm

I was anxious to start using PeakClick so I could give it a useful review. However, I came across an obstacle in implementing their feed. My host, Dreamhost, has file() disabled as a safety against hacking. This means that to use the PeakClick feed on Dreamhost, you need to use cURL (a php function).

The problem is that I would imagine many people who use these kinds of PPC feeds don’t know much about php and just copy and paste what PeakClick gives them. That’s certainly what I tried to do at first. Remember that customer service I spoke of that PeakClick prides themselves on so much that they make it a main selling point? Well, their exact reply to my problem was “there is most likely a bug in your script with curl, please try to debug it.” Granted, I understand it’s not their job to teach me php, but I was hoping for many a little snippet of code or atleast a resourceful link. So I decided to look for another solution to my problem.

What I found was SimpleXML. Its a great, easy way to integrate XML without any hard work. You don’t even have to know anything about php. The one requirement is that your server is running php 5. For Dreamhost this is no problem, simply go to “manage domains” and then edit your domain and click the “PHP 5″ option. Then just add the SimpleXML code into your webpage wherever you want the PeakClick feed to appear. Here is the complete code:

################## CONFIGURATION #######################
$_aff = 0000; # Your Affiliate ID
$_subaff = 1; # Your Subaffiliate ID
$_numResults = 5; # Number of search results displayed
$_ip = $_SERVER["REMOTE_ADDR"];
$keyword = "yourkewordhere";
############################################################
// sets the name of XML file
$file = "http://feed.peakclick.com/res.php?aff=$_aff&subaff=$_subaff" . ( $keyword != "" ? "&keyword=" . urlencode( $keyword ) : "" ) . "&num=$_numResults&ip=$_ip&thumbs=1&xml=1";
// loads the file
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
foreach( $xml->result as $result )
{
foreach($result->record as $record)
{
#### This part determines how the results look ####
echo “<div id=\”record\”>”;
echo “<a href=\”" . $record->click . “\”>”;
echo “<h3> ” . $record->title . “</h3>”;
echo ” <dl ><dt>” . $record->thumbnail . “</dt> <dd>” . $record->description . “</dd></dl>”;
echo “</a>”;
echo “</div>”;
############################################################
}
}
?>

It’s really so easy. The only part you would need to change is the output. You’d probably want to style the way it looks but that can easily be done with style sheets. And you can change anything in the “echo” statements to suite your needs.


Fatal error: Call to undefined function: the_bunny_tags() in /home/.georgie/is5des/blog/wp-content/themes/loft/single.php on line 23