インスタ api 画像表示
・アクセストークン取得
http://nxpg.net/blog/?p=7190
・エラー
{“code”: 403, “error_type”: “OAuthForbiddenException”, “error_message”: “Implicit authentication is disabled”}
http://aws2000.net/?p=1189
・出力
insta.php
1 2 3 4 5 6 | <?php if ( $_SERVER [ 'REQUEST_METHOD' ] == 'POST' ){ $access_token = "アクセストークン" ; echo @ file_get_contents ( "https://api.instagram.com/v1/users/self/media/recent/?access_token={$access_token}" ); exit ; } |
view.html
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | < script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js" ></ script > < script > $(function() { $("#instagram").text("Loading..."); var html = ''; $.ajax({ url: "insta.php",//PHPファイルのURL、適宜変更 type:"POST", dataType: "json" }).done(function(data){ $("#instagram").text(""); var length = data.data.length; for (var i = length -1; 0 <= i; i--) { var d = data.data[i]; html += '< a href = "' + d.link + '" target = "_blank" >< img src = "' + d.images.low_resolution.url + '" width = "200" height = "200" ></ a >'; } }).fail(function(){ html = 'Loading...'; }).always(function(){ $("#instagram").html(html); }); }); </ script > < div id = "instagram" ></ div > </ body > |