Google Image Search

<?php //http://mikefigueroa.com/blog/2011/08/get-first-google-image-search-result-with-php/
if(isset($_GET['q'])){
 $n= (isset($_GET['n']))? $_GET['n']: '0';
 $q = urlencode($_GET['q']);
 $jsonurl = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=".$q;
 $result = json_decode(file_get_contents($jsonurl), true);
 header("Content-Type: image/jpg");
 $img = imagecreatefromjpeg($result['responseData']['results'][$n]['tbUrl']);
 imagejpeg($img);
 imagedestroy($img);
 exit;
}?>

구글 이미지 검색을 이용해서 뭔가를 만들었습니다.

참고한 것은 http://mikefigueroa.com/blog/2011/08/get-first-google-image-search-result-with-php/ 이것이구요..

위키의 꼬리표(태그)를 이용해서 관련 이미지를 검색한 후 자동으로 보여주는 것이었는데…

<?php //http://mikefigueroa.com/blog/2011/08/get-first-google-image-search-result-with-php/
if  (($INFO['namespace']!="") && ($ACT====='show')) {
$tags=p_get_metadata($ID, 'subject'); shuffle($tags);
$_id=  "".implode("+",array_slice($tags,0,2));
$_query=urlencode($_id);
echo "<table><td><a href='http://www.google.ca/images?q={$_query}' target='_blank'><img src='http://media.vaslor.net/fgi.php?q={$_query}' title='{$_id}' style='max-width:160px' alt='Nope!' /></a></td>";
echo "<td><a href='http://www.google.ca/images?q={$_query}' target='_blank'><img src='http://media.vaslor.net/fgi.php?q={$_query}&n=1' title='{$_id}' style='max-width:160px' alt='Nope!' /></a></td>";
 
echo "<td><ul><li>옆의 사진은 구글이미지검색에서 <b style='color:black'>{$_id}</b>로 찾아온 것입니다.</li><li>본 위키는 해당 사진에 대한 권리나 책임이 없습니다. </li><li>이 기능은 테스트 중이며 본 페이지의 내용과 전혀 관련이 없을 수도 있습니다.</li><li>  <a href='http://www.google.ca/images?q={$_query}' target='_blank'>구글이미지 검색에서 보기</a></li> </ul></td></table>";
   }
?>

언제부터인가 작동이 안되어서 들여다 봤더니…

{"responseData": null, 
"responseDetails": "Suspected Terms of Service Abuse. 
Please see http://code.google.com/apis/errors", 
"responseStatus": 403}

라고 나옵니다…

너무 많이 썼다는 거죠… 부하가 걸렸나? 기껏 찾아온 사람을 외부로 보내는 것이 좀 말이 안된다는 생각은 하고 있었는데, 흠.. 삭제해야 겠습니다.

누구나 수정하실 수 있습니다. 위키 사용법 참고하세요.