Loading ...
Sorry, an error occurred while loading the content.
 

Re: Stumped on YBOSS Geo API

Expand Messages
  • midwest_turtle
    Sorry about the previous question. My fault. I figured it out. Essentially I had two libraries requests and requests-oauthlib. requests (current) is broken as
    Message 1 of 2 , Aug 24, 2013
      Sorry about the previous question. My fault. I figured it out.

      Essentially I had two libraries requests and requests-oauthlib. requests (current) is broken as is requests-oauthlib

      In the first example that failed, I was using the wrong library. To fix this, I uninstalled everything related to requests, oauth - installed requests from scratch (really old version) like so

      pip install -I requests==0.14.0

      After that everything was happy and humming.

      Thanks!


      --- In ysearchboss@yahoogroups.com, "midwest_turtle" <vasuki.nagendra@...> wrote:
      >
      > Hi,
      > I am completely stumped on the Geo API, wondering if anyone has any ideas. Here is what I have
      > 1. Python - 2.7.3, Virtual env
      > 2. pip list shows
      > haversine (0.1)
      > httplib2 (0.8)
      > oauth2 (1.5.211)
      > oauthlib (0.5.1)
      > requests (0.14.0)
      > requests-oauthlib (0.3.3)
      > 3. I have signed up for the BOSS API, with my credit card information (no errors)
      > 4. My domain setup there is "mydomain.com", but I am trying to test code on a test server that does NOT resolve to "mydomain.com" (mydomain being an example of course)
      >
      > I have looked through this forum, found two samples
      >
      > import requests
      > from requests.auth import OAuth1
      >
      > url = u'http://yboss.yahooapis.com/geo/placefinder'
      > consumer_key = u'...'
      > consumer_secret = u'.....'
      >
      > queryoauth = OAuth1(consumer_key, consumer_secret)
      > response = requests.get(url,
      > params={'location':'Philly'}, auth=queryoauth)
      >
      > [requests currently is broken/not working - if you want to test this, you need to do a pip install of the requests version in the pip list posted above]
      > This fails with ValueError: GET/HEAD requests should not include body.
      >
      > The other sample I found was this
      > import oauth2 as oauth
      >
      > import time
      >
      > import urllib, urllib2
      >
      >
      > def get_response(buckets,params):
      >
      > url = "http://yboss.yahooapis.com/geo/" + buckets
      > cc_key = u'...'
      > cc_secret = u'...'
      >
      > consumer = oauth.Consumer(cc_key,cc_secret)
      >
      > req = oauth.Request(method="GET", url=url, parameters=params)
      >
      > signature_method = oauth.SignatureMethod_HMAC_SHA1()
      >
      > req.sign_request(signature_method, consumer, None)
      >
      > response = urllib2.urlopen(req.to_url())
      >
      > return response.read()
      >
      >
      >
      > buckets = 'placefinder'
      >
      > params = {
      >
      > 'oauth_version': "1.0",
      >
      > 'oauth_nonce': oauth.generate_nonce(),
      >
      > 'oauth_timestamp': int(time.time()),
      >
      > 'q': '701+first+avenue,sunnyvale+CA',
      >
      > 'count': '1',
      >
      > 'format': 'J',
      >
      > }
      > print get_response(buckets,params)
      >
      > Fails with urllib2.HTTPError: HTTP Error 400: Bad Request. I tried both format:J and format json -- same result
      >
      > Any help/pointers on what is going on, where I should look would be very much appreciated!
      >
      > Thanks!
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.