Hi david,
I was wandering if you have some code that can verify a merchants website via a meta tag? Lets say if the merchant put the meta tag in his head section of his website, a verified image will show next to merchant prices and logo's?
Thanks for your great support
jacques
Hi David,
Thanks for this code. This is exactly what I wanted.
Thanks
Jacques
That sort of verification is very straight forward to do in principle, but you probably don't want to have HTTP requests made to every merchant featured on a page for every page view (both for the page load time, and the bandwidth hit for both you and your merchants).
But as a simple coding example, if you ask your merchant to add the following meta tag to the <head> section of their website:
<meta name="yourwebsite-verification" content="verification-code" />
Then the code on your server to fetch and perform the verification would be something like:
<?php
$html = file_get_contents("http://www.example.com/");
preg_match_all('/meta[\s]+name=["\'](.*)["\'][\s]*content=["\'](.*)["\']/i',$html,$matches);
$meta = array();
foreach($matches[1] as $i => $key)
{
$meta[strtolower($key)] = $matches[2][$i];
}
if ($meta["yourwebsite-verification"] == "verification-code")
{
print "Verified!";
}
?>
Verification by file is even easier, you might ask a merchant to add a file to their website:
yoursite-theirverification-code.html
And then to verify is simply:
<?php
if (file_exists("yoursite-theirverification-code.html"))
{
print "Verified!";
}
?>
Both the above require that allow_url_fopen is permitted in your PHP configuration, but if not, and you're not able to modify it then cURL could be used just as easily.
Hope this points you in the right direction!
Cheers,
David.
--
PriceTapestry.com