android - Cannot get URL (with sql query) to be handled by DefaultHttpClient in java -


i've been struggling half day trying learn , stuck. goal query finance data yql yahoo finance tables. have set code androidhive example , able running correctly sample query. sample query grabs json object directly main url provide. yql, need convert sql query format httpclient recognize, , app keeps hanging , never returning response.

first, tried taking exact query string yql replicate search, me this:

https://query.yahooapis.com/v1/public/yql?q=select%20symbol%2cchange%20from%20yahoo.finance.quote%20where%20symbol%20in%20(%22sh%22%2c%22dog%22%2c%22rwm%22)&format=json&env=store%3a%2f%2fdatatables.org%2falltableswithkeys&callback=

that gives me null result when set url = above, , run following:

defaulthttpclient httpclient = new defaulthttpclient(); . . . httpget httpget = new httpget(url);     httpresponse = httpclient.execute(httpget); 

if androidhive example url in code, works fine. if enter above url in browser, works fine. clearly, url not being entered correctly.

so read online need use urlencode convert syntax of url correct format. here's did:

private string url = "https://query.yahooapis.com/v1/public/yql?q=" +urlencoder.encode("select symbol, change yahoo.finance.quote symbol in (\"sh\",\"dog\".\"rwm\")")+"&format=json&env=store%3a%2f%2fdatatables.org%2falltableswithkeys&callback="; 

that gives me 2 problems. first, tells me encode deprecated, , supposed use new syntax adds "utf-8" second string parameter, when that, compiler error of java.io.unsupportedencodingexception (ugh), tried running deprecated form, leaves app hanging forever original format.

i must doing obvious incorrect here...


okay - updated.

https!!! versus http. sample query did androidhive example http , yql query had https. if change http works, , didn't need urlencoder business. string directly yql worked.

now need start solving json parsing bugs, i've got data!


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -