SNS [Instagram][PHP] 해시태그 검색 이미지 가져오기 #2 (Json 활용한 데이타 추출)
페이지 정보
본문
Json 활용한 인스타그램 데이타 추출하기
<?php
// 원제작 : mulder21c's 실험실 ( http://www.publisher.name/lab/h/instagram )
// 수정 : 해피정닷컴 ( https://www.happyjung.com/lecture/2005 )
// instagram 으로부터 REST 호출
//$instaContents = file_get_contents("https://api.instagram.com/v1/users/self/media/recent?client_id=[My Client ID]&access_token=[My Access Token]&count=[추출수]");
//$instaContents = file_get_contents("https://api.instagram.com/v1/tags/[키워드]/media/recent?access_token=[ACCESS_TOKKEN]&count=[추출수]");
$instaContents = file_get_contents("https://api.instagram.com/v1/tags/셰프존/media/recent?access_token=2261712023.c6bfe0e.7f6b5b1091c245519a82f144c0f24ff2&count=4");
$instObj = json_decode($instaContents)->data;
// 받아온 json data 재가공
for($i = 0; $i < count($instObj); $i++){
//$json_data[$i] = array($instObj[$i]->images->thumbnail->url, str_replace("\n"," ",$instObj[$i]->caption->text)); // 150 x 150
$json_data[$i] = array($instObj[$i]->images->low_resolution->url, $instObj[$i]->link, str_replace("\n"," ",$instObj[$i]->caption->text)); // 320 x 320
//$json_data[$i] = array($instObj[$i]->images->standard_resolution->url, str_replace("\n"," ",$instObj[$i]->caption->text)); // 640 x 640
echo "<a href='".$json_data[$i][1]."' target='_blank' title='".$json_data[$i][2]."'><img src='".$json_data[$i][0]."' style='width:43%; margin:3px 4px;' alt='".$json_data[$i][2]."'></a>";
if ($_SERVER['REMOTE_ADDR'] == "106.243.93.251") {
//echo $json_data[$i][$i];
}
}
// 새로운 json data encode
//echo "test1111";
//echo("json_data =======>".$instaContents);
//print_r($instObj);
if ($_SERVER['REMOTE_ADDR'] == "106.243.93.251") {
//echo $json_data[$i][$i];
//echo $jsonR;
}
?>
<?php
// 원제작 : mulder21c's 실험실 ( http://www.publisher.name/lab/h/instagram )
// 수정 : 해피정닷컴 ( https://www.happyjung.com/lecture/2005 )
// instagram 으로부터 REST 호출
//$instaContents = file_get_contents("https://api.instagram.com/v1/users/self/media/recent?client_id=[My Client ID]&access_token=[My Access Token]&count=[추출수]");
//$instaContents = file_get_contents("https://api.instagram.com/v1/tags/[키워드]/media/recent?access_token=[ACCESS_TOKKEN]&count=[추출수]");
$instaContents = file_get_contents("https://api.instagram.com/v1/tags/셰프존/media/recent?access_token=2261712023.c6bfe0e.7f6b5b1091c245519a82f144c0f24ff2&count=4");
$instObj = json_decode($instaContents)->data;
// 받아온 json data 재가공
for($i = 0; $i < count($instObj); $i++){
//$json_data[$i] = array($instObj[$i]->images->thumbnail->url, str_replace("\n"," ",$instObj[$i]->caption->text)); // 150 x 150
$json_data[$i] = array($instObj[$i]->images->low_resolution->url, $instObj[$i]->link, str_replace("\n"," ",$instObj[$i]->caption->text)); // 320 x 320
//$json_data[$i] = array($instObj[$i]->images->standard_resolution->url, str_replace("\n"," ",$instObj[$i]->caption->text)); // 640 x 640
echo "<a href='".$json_data[$i][1]."' target='_blank' title='".$json_data[$i][2]."'><img src='".$json_data[$i][0]."' style='width:43%; margin:3px 4px;' alt='".$json_data[$i][2]."'></a>";
if ($_SERVER['REMOTE_ADDR'] == "106.243.93.251") {
//echo $json_data[$i][$i];
}
}
// 새로운 json data encode
//echo "test1111";
//echo("json_data =======>".$instaContents);
//print_r($instObj);
if ($_SERVER['REMOTE_ADDR'] == "106.243.93.251") {
//echo $json_data[$i][$i];
//echo $jsonR;
}
?>
댓글목록
등록된 댓글이 없습니다.