Created
December 24, 2011 19:38
-
-
Save aerith/1518176 to your computer and use it in GitHub Desktop.
instagram 用のデモページ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" charset="UTF-8"></script> | |
<title>Play with Instagram - sample</title> | |
</head> | |
<body> | |
<div class="content container"> | |
<a href="https://instagram.com/oauth/authorize/?client_id=[クライアントID]&redirect_uri=[リダイレクト用のURL]&response_type=token">allow the application to use data on instagram</a> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" charset="UTF-8"></script> | |
<title>Play with Instagram - sample</title> | |
<script type="text/javascript"> | |
<!-- | |
function onPageLoad () { | |
if (window.localStorage) { | |
var access_token = window.localStorage.getItem('instagram-access-token'); | |
var endpoint = 'https://api.instagram.com/v1/users/self/feed?access_token=' + access_token; | |
jQuery.ajax(endpoint, { dataType: 'jsonp', jsonpCallback: 'onDataLoad' }); | |
} | |
} | |
// Go to see: http://api.jquery.com/jQuery.ajax/ | |
function onDataLoad (result) { | |
var length = result.data.length; | |
for (var i = 0; i < length; i++) { | |
var item = result.data[i]; | |
var div = document.createElement('div'); | |
div.innerHTML = '<p><img src="' + item.images.thumbnail.url + '"></p>'; | |
document.body.appendChild(div); | |
} | |
} | |
--> | |
</script> | |
</head> | |
<body onload="onPageLoad();"> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" charset="UTF-8"></script> | |
<title>Play with Instagram - sample</title> | |
<script type="text/javascript"> | |
<!-- | |
function onPageLoad () { | |
var query_parameters = {}; | |
var fragment_parameters = {}; | |
var access_token = null; | |
var query = location.search.toString(); | |
var fragment = location.hash.toString(); | |
if (query.length > 1) { | |
// ? が含まれるので。 | |
query_parameters = getParameters(query.substring(1)); | |
} | |
if (fragment.length > 1) { | |
// # が含まれるので。 | |
fragment_parameters = getParameters(fragment.substring(1)); | |
} | |
// アクセストークンがないのでエラー | |
if (!("access_token" in fragment_parameters)) { | |
alert(query_parameters.error_description.split('+').join(' ')); | |
location.href = '/demo/'; | |
} else { | |
access_token = fragment_parameters.access_token; | |
if (window.localStorage) { | |
window.localStorage.setItem('instagram-access-token', access_token); | |
location.href = '/demo/page.html'; | |
} | |
} | |
} | |
function getParameters (str) { | |
var result = {}; | |
var pairs = str.split('&'); | |
var pair = null; | |
for (var i = 0; pair = pairs[i]; i++) { | |
var pieces = pair.split('='); | |
if (pieces[0] && pieces[1]) { | |
result[decodeURIComponent(pieces[0])] = decodeURIComponent(pieces[1]); | |
} | |
} | |
return result; | |
} | |
--> | |
</script> | |
</head> | |
<body onload="onPageLoad();"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment