Visits and returns the content of any endpoint via get, post, put, or delete. You can use this tool to push data to a remote restful api or pull data in from one.
{ status : 200, message : 'ok', request_method : 'get', requested_url : 'http://bit.ly/sf_trends', redirected_url : 'http://api.twitter.com:80/trends.json', headers : 'X-RateLimit-Remaining=128', response : { "trends":[{...}, {...}], "locations":[{"name":"San Francisco","woeid":2487956}], "as_of":"2011-11-21T20:29:10Z"} } }
{ status : 400, message : 'Required parameters missing. Hint: no url provided', response : {} }
<script type="text/javascript"> var remote_url = "http://api.twitter.com/1/trends/2487956.json" var fetch_timeline = function() { sml.web.Request.get(remote_url,{ success: function(data) { console.log(data); }, error: function() { alert("request failed"); } }); } </script> <a href="#_" onclick="fetch_timeline();">Fetch Twitter Trends for San Francisco</a>
<script type="text/javascript"> ... // somewhere in the onSubmit handler ... var remote_url = "http://api.your_restful_website.com/signup/create"; var body_args = { email : $.('#email_field').val(), name : $.('#full_name_field').val(), other_field : $.('#some_other_field').val() }; sml.web.Request.post(remote_url,{ params : { app_token : '4eFg40....3kfksd' }, body : body_args, success: function(data) { $.('#some_spinner).hide(); $.('#successfully_posted_data).show(); }, error: function() { $.('#some_spinner).hide(); $.('#did_not_successfully_post_data).show(); } }); ... </script>