Witam mam problem może mi ktoś napisać taką funkcje? mam zmienna $bez_niczego
i niech funkcja wpisuje w google image zawartosc zmiennej $bez_niczego np kot i wkleja pierwszy obrazek na stronie mam taka klase ale coś nie działa
i niech funkcja wpisuje w google image zawartosc zmiennej $bez_niczego np kot i wkleja pierwszy obrazek na stronie mam taka klase ale coś nie działa
class getGoogleImage { public $img = null; public function __construct($query, $start = 0, $max_w = false, $max_h = false) { $link = "http://www.google.pl/search?num=20&hl=pl&site=imghp&tbm=isch&source=hp&q={$query}&btnG=Wyszukiwanie+obrazem&gbv=1&sei=hgORULnBBsyO4gTNLw&start=$start"; $source = $this->getSource($link); if(!$source) foreach($explode as $e) { { if($max_h && $max_w) { $height = $height[0]; { $this->img = $img[0]; break; } } else { $this->img = $img[0]; break; } } } if($this->img == NULL) { $this::__construct($query, $start + 20, $max_w, $max_h); } } public function getImage() { return $this->img; } public function getSource($URL) { $c = curl_init(); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_URL, $URL); $s = curl_exec($c); curl_close($c); if ($s) return $s; else return false; } }
użycie
$obrazek = new getGoogleImage('kot', 0, 400, 400);