Created
February 21, 2012 11:08
-
-
Save timhodson/1875891 to your computer and use it in GitHub Desktop.
Kasabi: Quick example of using the Attribution API
This file contains hidden or 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
| ############################################# | |
| ## Quick and dirty curl | |
| ############################################# | |
| # Get a snippet of javascript | |
| curl -v -X GET "http://api.kasabi.com/dataset/nasa/attribution" | |
| # Get the attribution as JSON | |
| curl -v -X GET "http://api.kasabi.com/dataset/nasa/attribution?output=json" | |
| ############################################# | |
| ## Javascript snippets for your HTML pages | |
| ############################################# | |
| # Either add the following <script> tag to your HTML page where you want the attribution to appear | |
| <script type="text/javascript" src="http://api.kasabi.com/dataset/nasa/attribution"></script> | |
| # Or use jQuery to get the attribution text and display it in your own markup | |
| $('document').ready(function() { | |
| $.ajax({ | |
| url: "http://api.kasabi.com/dataset/nasa/attribution?output=json", | |
| success: function(data) { | |
| $('.myAttributionClass').html("Data from the <a href=\"" + data['homepage'] + "\"\ntitle=\"" + data['name'] + "\"><b>" + data['name'] + "</b> dataset</a> \nProvided by: <a href=\"" + data['source'] + "\">Kasabi</a>"); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment