인스타그램 API없이 JSON Data로  가져오는 방식입니다.

 

현재 인스타그램의 업데이트로 인하여 이 코드는 작동을 안합니다.

좀더 개선되었습니다. ^^ 추후 업데이트된 게시물 올리겠습니다.

 

<?php
//tag 기준 $baseUrl = "https://www.instagram.com/explore/tags/$tag/?__a=1";
$url = $baseUrl;

while(1) {
    $json = json_decode(file_get_contents($url));
    print_r($json->tag->media->nodes);
    if(!$json->tag->media->page_info->has_next_page) break;
    $url = $baseUrl.'&max_id='.$json->tag->media->page_info->end_cursor;
}
<?php
//user id 기준  $user="somin_jj";
$baseUrl = "https://www.instagram.com/$user/?__a=1";
$url = $baseUrl;
while(1) {
    $json = json_decode(file_get_contents($url));
    print_r($json->user->media->nodes);
    if(!$json->user->media->page_info->has_next_page) break;
    $url = $baseUrl.'&max_id='.$json->user->media->page_info->end_cursor;
}

 

natura

profile
취미로 개발하는 사람입니다.
  • profile
    somin_jj!! 닉변하신 겁니까ㅎㅎ
  • profile profile
    네~
    원래는 한글자 생각해두었는데 두글자부터라서 느낌표를 붙였네요
  • profile
    위 코드를 이용해서 사진과 링크등을 웹에 표시하려면 어떤식으로 코딩하면 되나요?....제가 이쪽으로는 거의 무지한 상태라 활용하기가 좀 힘듭니다....간단하게라도 사진을 표시하는 정도만 알려주실수 있으실까요;;;;
  • profile profile
    지금 폰이라 나중에 알려드릴께요 .
  • profile profile
    <?php
    //user id 기준
    $user="somin_jj";
    $baseUrl = "https://www.instagram.com/$user/?__a=1";
    $url = $baseUrl;
    while(1) {
    $json = json_decode(file_get_contents($url));
    $media =$json->user->media->nodes;

    //반복문
    foreach($media as $key=>$value){
    echo <<<EOD
    <img src="{$media[$key]->display_src}">
    EOD;
    }
    if(!$json->user->media->page_info->has_next_page) break;
    $url = $baseUrl.'&max_id='.$json->user->media->page_info->end_cursor;
    }

    ?>
  • profile profile
    감사합니다 덕분에 잘 해결했습니다^^