차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
tech:google_image_search [2013/01/14 11:24] V_Ltech:google_image_search [2016/07/12 00:56] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 +{{tag>google image search}}
 +======Google Image Search======
 +
 +<code php>
 +<?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;
 +}?></code>
 +
 +구글 이미지 검색을 이용해서 뭔가를 만들었습니다.
 +
 +참고한 것은 http://mikefigueroa.com/blog/2011/08/get-first-google-image-search-result-with-php/ 이것이구요..
 +
 +위키의 꼬리표(태그)를 이용해서 관련 이미지를 검색한 후 자동으로 보여주는 것이었는데...
 +
 +<code 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>";
 +   }
 +?></code>
 +
 +
 +언제부터인가 작동이 안되어서 들여다 봤더니...
 +
 +<code json>{"responseData": null, 
 +"responseDetails": "Suspected Terms of Service Abuse. 
 +Please see http://code.google.com/apis/errors", 
 +"responseStatus": 403}</code>
 +
 +라고 나옵니다...
 +
 +너무 많이 썼다는 거죠... 부하가 걸렸나?
 +기껏 찾아온 사람을 외부로 보내는 것이 좀 말이 안된다는 생각은 하고 있었는데,
 +흠.. 삭제해야 겠습니다.
 +
 +
 +
 +^  누구나 수정하실 수 있습니다. [[http://vaslor.net/syntax|위키 사용법]] 참고하세요. ^
 +