create a PPC Search engine with PHP and Searchfeed
Author: Nick PapanotasYou visited a few times and I would appreciate your thoughts on this post, why not comment?
So you want to start your own ppc search engine? A ppc search engine may be a good additional income, and you can easilly add it to an established site, or maybe start a new one just for this.
What do I need to start my own ppc search engine?
Well to start you will need a third party network which will provide you the search results. The business scheme is very easy to understand. They give you an automatically way to fetch results based on the keywords that your visitors use to search your site and they pay you for every click that your users do in those results.
Selecting an advertising network for search results
In the past I have used many networks but the only one that was reliable for me was SearchFeed. So in this tutorial I will help you create a ppc search engine using SearchFeed.
Creating your own PPC search engine with SearchFeed
Before you start you will need an account with SearchFeed. If you don’t, use this link to register one, and then come back for the rest of this tutorial
The basics
Login to your account at SearchFeed, and go to Integration Tools > XML and Text Usage. From there you will see your track identification number (trackID) and your partner identification number (pID). Those are very important as they are used by SearchFeed to assign the clicks to your account.
The script. Time to create our php search engine
The above code is very basic. I suppose that you allready have some PhP knowledge in order to work this out. Of course if you have troubles using it you can allways post a question to a PhP forum
function searchFeedResults($q, $results, $tID, $pID)
{
$res = array();
$url = "http://www.searchfeed.com/rd/feed/TextFeed.jsp";
$url.= "?trackID=".$tID."&excID=&pID=".$pID."&cat=";
$url.= urlencode($_GET['q']).”&nl=”;
$url.= $results.”&page=1&ip=”.$_SERVER["REMOTE_ADDR"];
$ret=file($url);
if ( count($ret) == 0 ) return $res;
for ( $i=0;$i
$j = $i;
for ( $j=$i;$j<($i+4);$j++)
{
$a = explode('|',$ret[$j]);
$tmp[] = $a[2];
}
$res [] = $tmp;
unset($tmp);
}
return $res;
}
This function (searchFeedResults) gets the results and returns an array with them. The parameters are :
- $q => The query (search terms)
- $results => How many results to display
- $tID => Your SearchFeed track id
- $pID => Your SearchFeed partner id
How to use the script
Here is a common usage of the script. I suppose that the user is using $_GET['q'] to send a query. So here is how we can parse it:
$results = searchFeedResults($_GET['q'], 20, $myTid, $myPid);
if ( $results ){
foreach ( $results as $rec ){
echo ‘
<p>
<a href=”‘.$rec[2].’” onmouseover=”window.status=\’http://’.$rec[1].’\'; return true”
onmouseout=”window.status=\’ \’; return true”>’.$rec[0].’</a><br />
‘.$rec[3].’<br />
<small>’.$rec[1].’</small>
</p>’;
}
}else{
echo ‘No results for ‘.$_GET['q'].’<br /><br />’;
}
Conclusions
Hope you like our script. By the way I have also added a full working script, which you can download here.

































John
from Php user class2007-06-12 18:59:11
Nice script. Thanks for sharing this
Steven
2007-06-14 01:17:04
Thanks for the info. Might be able to put it to use.
admin
from Webdigity webmaster forums2007-06-15 12:10:11
The script is now featured at hotscripts. Feel free to rate it
http://www.hotscripts.com/Detailed/70981.html
Turnkey Websites
2007-07-04 00:46:43
I really like your script, good work!
Nathan
from USGDirect!!!2008-01-11 07:37:38
I am wanting to figure out how to build an internal PPC search engine. The search part is easy but how could I maintain tracking etc. Is there a out of the box solution for this. I have been researching on google and i found this site. Looks like you show how to sign up for one and integrate it into your site but I want to build one. You know build my own Google Adwords…