transmission line noise

home

Dash­code and cURL

09 Sep 2009

Tagged with Miscellaneous

Need to get data from another site well you can use cURL to get it.
widget.system("/usr/bin/curl http://api.asite.com/rates/rate.php?pair=EUR/CHF", null).outputString;
this will pull the rate as a json string, but as the site needs authen­ti­ca­tion it actu­ally won’t, it will fall over. In php i would set this up with curl_opt but in dash­code i am not able to use php.

How­ever run man curl and scru­ti­nise the options and you see
-u/--user <user :password></user>

sub­sti­tute the cor­rect infor­ma­tion and the string looks like this:-
widget.system("/usr/bin/curl --user johnh:aranaio http://api.worldfirst.com/rates/rate.php?pair=EUR/CHF", null).outputString;

and that does the trick.

comments powered by Disqus