Nouveau WRInaute
			
		Bonjour,
Je cherche une façon simple d'afficher une image google (la + pertinente) sur mon site internet associatif.
Il y a quelques année j'utilisai ce script :
	
	
	
		
Mais ca ne fonctionne plus 
J'ai cherché dans la doc de google (https://developers.google.com/custom-search/docs/overview) mais à moins d'être un ingénieur de la NASA je ne trouve rien !
Est ce que quelqu'un à une idée ?
Merci
				
			Je cherche une façon simple d'afficher une image google (la + pertinente) sur mon site internet associatif.
Il y a quelques année j'utilisai ce script :
		PHP:
	
	// utilisation de JSON sur Google Images pour afficher une photo
// https://developers.google.com/image-search/v1/jsondevguide#userip
// objet a chercher
$searchGoogle = $products['marque'].' '.$NomProduit;
// création requete
$url = "https://ajax.googleapis.com/ajax/services/search/images?" .
      "v=1.0&q=".urlencode($searchGoogle)."&userip=".$_SERVER['REMOTE_ADDR']."&rsz=2&imgtype=photo&imgsz=medium&hl=fr";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $adresse_page);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 2000);
$body = curl_exec($ch);
curl_close($ch);
$obj = json_decode($body, true);
// si il y a une réponse
if ($obj['responseStatus'] == '200')
{
    foreach ($obj['responseData']['results'] AS $valeur)
    {
            $largMax = '300';
            $hautMax = '300';
            $googleWidth = $valeur['width'];
            $googleHeight = $valeur['height'];
            if (@fopen($valeur['url'], "r"))
            {
                    // affichage de la photo propose par google
                    echo '<img src="'.urldecode($valeur['url']).'"';
                    if (!empty($googleWidth) AND !empty($googleHeight))
                    {
                            echo ' style="width:'.$googleWidth.'px;height:'.$googleHeight.'px;"';
                    }
                    echo ' alt="'.htmlentities($valeur['titleNoFormatting'],ENT_QUOTES,"UTF-8").'" />';
            }
    }
}
J'ai cherché dans la doc de google (https://developers.google.com/custom-search/docs/overview) mais à moins d'être un ingénieur de la NASA je ne trouve rien !
Est ce que quelqu'un à une idée ?
Merci

 
 
		

 
     
 
		 
 
		 
 
		