B
adge
W
izard
[API Document]
[API Explorer]
검색어를 입력하세요
TAG
사용자 아이디
그룹
최근 사진
사진 크기를 선택하세요
사각형
75px X 75px
썸네일
긴축 100px
작은 크기
긴축 240px
사진을 배치하세요
색상을 선택하세요
배경
#
테두리
#
사진 테두리
#
Color Table
결과 보기
결과
HTML
XML
PHP
<?php $category = $_GET['category']; $flickrinput = $_GET['flickrinput']; $size = $_GET['size']; $layout = $_GET['layout']; $url = "http://api.flickr.com/services/rest/?api_key=<your api key>&per_page=25"; if($category == "pop") $url .= "&method=flickr.photos.getRecent"; else if($category == "group_id") $url .= "&method=flickr.groups.pools.getPhotos&".$category."=".$flickrinput; else { $flickrinput = str_replace(" ", "+", $flickrinput); $url .= "&method=flickr.photos.search&".$category."=".$flickrinput; } // Open the Curl session $session = curl_init($url); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Make the call $response = curl_exec($session); curl_close($session); //this code is only available on PHP 5 //start //$rest_result = simplexml_load_string($response); //$rest_arr = $rest_result->photos->photo; //end //this is not a general parser. it's only worked for flickr :) //start $parse_arr = split("\n", $response); array_shift($parse_arr); if($parse_arr[0] == "<rsp stat=\"fail\">") exit(0); array_shift($parse_arr); array_shift($parse_arr); $rest_arr = array(); foreach($parse_arr as $p) { $preg_p = preg_split("/[\s=]+/", trim($p)); $temp_arr = array(); for($ii=1; $ii<count($preg_p)-1; $ii+=2) $temp_arr[$preg_p[$ii]] = substr($preg_p[$ii+1], 1, -1); array_push($rest_arr, $temp_arr); } //end $layout_row = preg_split("/\|/", $layout, -1, PREG_SPLIT_NO_EMPTY); $item_idx = 0; $str = "<table cellpadding=0 cellspacing=0 class='mytabletop'><td class='mytdtop'>"; $str .= "<table cellpadding=0 cellspacing=0 class='mytable'>"; for($i=0; $i<count($layout_row); $i++) { $layout_col = preg_split("/\,/", $layout_row[$i], -1, PREG_SPLIT_NO_EMPTY); $str .= "<tr class='mytr'>"; for($j=0; $j<count($layout_col); $j++) { if($layout_col[$j] == "1" && count($rest_arr)>$item_idx) { $img_url = "http://static.flickr.com/".$rest_arr[$item_idx]['server']."/".$rest_arr[$item_idx]['id']."_".$rest_arr[$item_idx]['secret']."_".$size.".jpg"; $img_link_url = "http://www.flickr.com/photos/".$rest_arr[$item_idx]['owner']."/".$rest_arr[$item_idx]['id']."/"; $str .= "<td class='mytd' align=center><a href='$img_link_url' target='_blank'><img src='$img_url' class='myimage'></a></td>"; $item_idx++; } else { $str .= "<td class='mytd'></td>"; } } $str .= "</tr>"; } $str.= "</table>"; $str.= "</td></table>"; ?> document.write("<?php echo $str?>");