i am wondering if someone knows how to get a random Image URL From Google in php ?
if got this code but its not working.
[php]<?php
function GetRandomImageURL($topic=’’, $min=0, $max=100)
{
// get random image from Google
if ($topic==’’) $topic=‘image’;
$ofs=mt_rand($min, $max);
$geturl=‘http://www.google.com/images?q=’ . $topic . ‘&start=’ . $ofs . ‘&gbv=1’;
$data=file_get_contents($geturl);
$f1=’
$f2=’<a href="/imgres?imgurl=’;
$f3=’&imgrefurl=’;
$pos1=strpos($data, $f1)+strlen($f1);
if ($pos1==FALSE) return FALSE;
$pos2=strpos($data, $f2, $pos1)+strlen($f2);
if ($pos2==FALSE) return FALSE;
$pos3=strpos($data, $f3, $pos2);
if ($pos3==FALSE) return FALSE;
return substr($data, $pos2, $pos3-$pos2);
}
?>[/php]
Thank you for your help and time in advance.