simple question about loadStrings() and URLs
in
Programming Questions
•
4 months ago
Hello, I'd like a widget to log my Xively (previously Cosm, Pachube) data to file. The data can be grabbed using their API. You enter a URL in your browser and you get CSV results. Eg:
http://api.xively.com/v2/feeds/76854.csv gives me the six latest readings from the weather station I've got sending data to Xively in the CSV structure <datastream name>, <timestamp>, <data>.
When I use loadStrings() to try and grab this data I get a 401. Any other URL I enter gives me the text of the html. Eg.
Can anyone tell me why this is the case?
Thanks,
NC
EDIT
Here's some code you can comment/uncomment to test the different URLs. The first two are for my data and don't work. The other two are just web pages and work. One of them is from the Xively site itself so there's no problem connecting to that server in particular.
-
//String[] lines = loadStrings("http://api.xively.com/v2/feeds/76854/datastreams/BMPp.csv");
//String[] lines = loadStrings("http://api.xively.com/v2/feeds/76854.xml");
String[] lines = loadStrings("https://xively.com/dev/docs/api/data/read/");
//String[] lines = loadStrings("http://processing.org/about/index.html");
println(lines);exit();
If you copy any of these URLs into your browser they all work as desired, just not in Processing.
1