Han Wu
Han Wu

Reputation: 1

How do I fail check a valid API?

I am using processing:

loadStrings("http://www.google.com/finance/info?q=" + sym);

The problem is that I want to be able to catch if sym is invalid instead of display a fake stock. Anyway to do this?

Upvotes: 0

Views: 72

Answers (1)

Michael Markidis
Michael Markidis

Reputation: 4191

I'm not sure exactly how the API works that you are using, but just quickly testing in a browser:

The request for http://www.google.com/finance/info?q=AADF (e.g. A bad stock)

will respond with "httpserver.cc: Response Code 400"

Can you just check for that response (A 400 Code)?

Upvotes: 1

Related Questions