実行結果' ; // エラー判定 if( !$obj || !isset($obj->data) ) { $html .= '

データを取得できませんでした…。設定を再確認して下さい。

' ; } else { foreach( $obj->data as $item ) { // 各データ $id = $item->id ; // メディアID $type = $item->type ; // メディアタイプ $link = $item->link ; // リンク $images = $item->images->low_resolution->url ; // 画像 $date = $item->created_time ; // 日付 (UNIX TIMESTAMP) $likes = ( isset($item->likes->count) ) ? $item->likes->count : 0 ; // ライク数 $comments = ( isset($item->comments->count) ) ? $item->comments->count : 0 ; // コメント数 // ユーザー情報 $user_id = $item->user->id ; // 投稿者ID $user_name = $item->user->username ; // 投稿者のユーザーネーム $user_full_name = ( isset($item->user->full_name) ) ? $item->user->full_name : '' ; // 投稿者のユーザーネーム $user_profile_picture = ( isset( $item->user->profile_picture ) ) ? $item->user->profile_picture : '' ; // アイコン画像 // 場所情報 $location_id = ( isset($item->location->id) ) ? $item->location->id : '' ; // 場所ID $location_name = ( isset($item->location->name) ) ? $item->location->name : '' ; // 場所名 $location_lat = ( isset($item->location->latitude) ) ? $item->location->latitude : '' ; // 緯度 $location_long = ( isset($item->location->longitude) ) ? $item->location->longitude : '' ; // 経度 // タグ情報 $tags = ( isset($item->tags) && !empty($item->tags) ) ? '#' . implode( '、#' , (array)$item->tags ) : '' ; // 日付の整形 $date = date( 'Y/m/d H:i' , $date ) ; // ブラウザに出力 $html .= '
' ; $html .= '
投稿者のID
' ; $html .= '
' . $user_id . '
' ; $html .= '
投稿者のユーザーネーム
' ; $html .= '
' . $user_name . '
' ; // フルネームがある場合 if( $user_full_name ) { $html .= '
投稿者のフルネーム
' ; $html .= '
' . $user_full_name . '
' ; } // アイコン画像がある場合 if( $user_profile_picture ) { $html .= '
投稿者のアイコン
' ; $html .= '
' ; } $html .= '
メディアID
' ; $html .= '
' . $id . '
' ; $html .= '
メディアタイプ
' ; $html .= '
' . $type . '
' ; $html .= '
メディアページ
' ; $html .= '
' . $link . '
' ; $html .= '
メディア
' ; // ユーザーのタグ付けがある場合 if( isset($item->users_in_photo) && !empty($item->users_in_photo) ) { $html .= '
' ; $html .= '
' ; $html .= '' ; // タグ付けされたユーザーを配置していく foreach( $item->users_in_photo as $user ) { if( isset($user->user->username) && isset($user->user->profile_picture) && isset($user->position->y) && isset($user->position->x) ) { $x = ( 250 * $user->position->x ) - 15 ; $y = ( 250 * $user->position->y ) - 15 ; $html .= '' ; } } $html .= '
' ; $html .= '

※' . count( $item->users_in_photo ) . '人のユーザーがタグ付けされています。

' ; $html .= '
' ; } else { $html .= '
' ; } $html .= '
投稿日時
' ; $html .= '
' . $date . '
' ; $html .= '
ライク数
' ; $html .= '
' . $likes . '
' ; $html .= '
コメント数
' ; $html .= '
' . $comments . '
' ; // 場所IDがある場合 if( $location_id ) { $html .= '
場所ID
' ; $html .= '
' . $location_id . '
' ; } // 場所名がある場合 if( $location_name ) { $html .= '
場所名
' ; $html .= '
' . $location_name . '
' ; } // 緯度、経度がある場合 if( $location_lat && $location_long ) { $html .= '
地図
' ; $html .= '
Google Mapsで位置を確認する
' ; } // ハッシュタグがある場合 if( $tags ) { $html .= '
タグ情報
' ; $html .= '
' . $tags . '
' ; } $html .= '
' ; } } // 取得したデータ $html .= '

取得したデータ

' ; $html .= '

下記のデータを取得できました。

' ; $html .= '

JSON

' ; $html .= '

' ; $html .= '

レスポンスヘッダー

' ; $html .= '

' ; // アプリケーション連携の解除 $html .= '

アプリケーション連携の解除

' ; $html .= '

このアプリケーションとの連携は、下記設定ページで解除することができます。

' ; $html .= '

https://instagram.com/accounts/manage_access/

' ; ?> Instagramで人気急上昇中の作品を取得するサンプルデモ

配布元: Syncer