-
Notifications
You must be signed in to change notification settings - Fork 43
javascript_index
Bruno Oliveira edited this page Feb 9, 2011
·
1 revision
This is a one minute guide to get you going with Restfulie. As soon as you finish this example you are up to the next guide and then move on to the features you want to explore more.
Configuration should always be minimal and programmatic. To use Restfulie simply install it:
<script type="text/javascript" charset="utf-8" src="restfulie.js"></script>
Or require its minified version
<script type="text/javascript" charset="utf-8" src="restfulie.min.js"></script>
The first part of Restfulie works as a typical http client, with a cuter interface.
The following example shows how to use it to access your system:
result = Restfulie.at("/my_user/my_user_timeline.xml").get();
alert("The response code was " + result.code);
# you can also use the result.body and result.headers
resource = result.resource;
for (statusIndex in result.resource.statuses.status){
tweet = resource.statuses.status[statusIndex];
console.log("username " + tweet.user.screen_name);
console.log("message " + tweet.text);
console.log("tweet created at " + tweet.created_at);
}
When runnning Javascript in a browser (not on node.js), javascript is not supposed to ajax to another website, thus Restfulie can not do it too: you need to proxy the invocations to any 3rd-party as you would with any other ajax library.