Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding some documentation on how to use the library
- Loading branch information
1 parent
bd55e42
commit a96cf2d
Showing
1 changed file
with
40 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
# Smugmug hAPIness | ||
# SmugMug hAPIness | ||
|
||
The hAPIness function wraps the complexities of creating valid and usable URLs for requests to the Smugmug API by requiring only the necessary information and allows for dependancy injection if desired for easier use. | ||
|
||
AN API is great for providing access to data but interacting with one is not something that is fun for us humans. | ||
AN API is great for providing access to data but interacting with one is not something that is fun for us humans. | ||
|
||
## Dependancies | ||
|
||
NONE! Well, JavaScript. | ||
|
||
The library doesn't have any external dependancies; this does also mean that it doesn't actually do any ajax requests for you or parameter string creation, you'll need to provide that based on your library of choice. | ||
|
||
## Usage | ||
|
||
First, you will need to include the `hAPIness.js` file in you project somehow; be that" | ||
|
||
``` | ||
<script src="hAPIness.js"></script> | ||
``` | ||
|
||
or via some other method. | ||
|
||
Then, you will need to configure it for your use. | ||
|
||
``` | ||
// use smugmug as the variable name to make you code fit the | ||
// API methods SmugMug provides; e.g. smugmug.albums.get() | ||
var smugmug = hAPIness("myAPIkey", "1.3.0"); | ||
// if you like using jQuery I suggest | ||
// this gives hAPIness the ability to fully create URLs for you | ||
hAPIness.setParamFn($.param); | ||
// now hAPIness can create URLs for you to use in ajax calls | ||
// again if you are using jQuery for ajax | ||
$.ajax({ | ||
dataType: "jsonp" | ||
,success: function (data) { | ||
// data.Albums is an array of all user's albums | ||
}) | ||
,url: smugmug.albums.get({NickName: "SmugMug_username"}) | ||
}); | ||
``` |