dbro / smspersonfinder

SMS interface to the Google Person Finder service
9 stars 6 forks source link

Appengine URL API for Search Doesn't Work From Browser #1

Open kevincon opened 13 years ago

kevincon commented 13 years ago

I tried visiting this url in my browser: http://smspersonfinder.appspot.com/search?message=Dan%20Brown

That should send the message "Dan Brown" to appengine.

I get this python traceback (most likely a problem with encoding/decoding URLs on both sides:

Traceback (most recent call last): File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/init.py", line 700, in call handler.get(_groups) File "/base/data/home/apps/s~smspersonfinder/1.350924882319313693/main.py", line 196, in get result = search.handle(message) File "/base/data/home/apps/s~smspersonfinder/1.350924882319313693/search/init.py", line 186, in handle data = urllib2.urlopen("%s%s" % (host, query_uri)).read() File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 124, in urlopen return _opener.open(url, data) File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 381, in open response = self._open(req, data) File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 399, in _open '_open', req) File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 360, in _call_chain result = func(_args) File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 1122, in https_open return self.do_open(httplib.HTTPSConnection, req) File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 1087, in do_open r = h.getresponse() File "/base/python_runtime/python_dist/lib/python2.5/httplib.py", line 197, in getresponse self._allow_truncated, self._follow_redirects) File "/base/python_runtime/python_lib/versions/1/google/appengine/api/urlfetch.py", line 260, in fetch return rpc.get_result() File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 592, in get_result return self.__get_result_hook(self) File "/base/python_runtime/python_lib/versions/1/google/appengine/api/urlfetch.py", line 358, in _get_fetch_result raise DownloadError(str(err)) DownloadError: ApplicationError: 2

lionelyoung commented 13 years ago

The code isn't urlencoding the string when using the web interface.

Try this:

Build query string

q = {'something': something, 'goes': goes, 'here': here}

query = urllib.urlencode(q)

url="http://smspersonfinder.appspot.com/search?%s" % query

dbro commented 13 years ago

this one word query works ok for me: http://smspersonfinder.appspot.com/search?message=bauer

kevincon commented 13 years ago

Yeah, unfortunately the issue has to do with using characters that require encoding, like spaces (which would become %20 in the URL). The appengine side is not expecting someone to input from a browser I think.

But I was thinking we should build in support for that, so if someone tried it they wouldn't see the Python traceback. :P

On Tue, Jun 7, 2011 at 4:34 PM, dbro < reply@reply.github.com>wrote:

this one word query works ok for me: http://smspersonfinder.appspot.com/search?message=bauer

Reply to this email directly or view it on GitHub: https://github.com/dbro/smspersonfinder/issues/1#comment_1323431