Created
April 27, 2012 16:07
-
-
Save sethladd/2510459 to your computer and use it in GitHub Desktop.
Instagram API with Dart
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
#import('dart:html'); | |
#import('dart:json'); | |
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
dataReceived(MessageEvent e) { | |
var data = JSON.parse(e.data); | |
print(data); | |
} | |
void main() { | |
// listen for the postMessage from the main page | |
window.on.message.add(dataReceived); | |
final client_id = "552faa062fdb495796233f9eb6297be2"; | |
ScriptElement script = new Element.tag("script"); | |
script.src = "https://api.instagram.com/v1/media/popular?client_id=$client_id&callback=callbackForJsonpApi"; | |
document.body.elements.add(script); | |
} |
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> | |
<title>dartstagram</title> | |
</head> | |
<body> | |
<h1>dartstagram</h1> | |
<h2 id="status">dart is not running</h2> | |
<script type="application/dart" src="dartstagram.dart"></script> | |
<script src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"></script> | |
<script type="text/javascript"> | |
function callbackForJsonpApi(s) { | |
window.postMessage(JSON.stringify(s), '*'); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment