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

RE: Python Solution for Yahoo! BOSS PlaceFinder

Expand Messages
  • vladathome
    Whatever I do I receive:
    Message 1 of 5 , Aug 29 11:59 AM
    • 0 Attachment

      Whatever I do I receive:


      <?xml version="1.0" encoding="utf-8"?> <yahoo:error xmlns:yahoo="http://yahooapis.com/v1/base.rng" xml:lang="en-US"> <yahoo:description>Rate Limit Exceeded</yahoo:description> <yahoo:detail>Key has exceeded its configured rate limit.</yahoo:detail> </yahoo:error>


      PLEASE HELP!!!

      See also: http://groups.yahoo.com/neo/groups/ysearchboss/conversations/topics/5511

       



      --- In ysearchboss@yahoogroups.com, <chris.brown@...> wrote:

      Here's a stripped down version of  what I'm using. (I ran this code and it worked but I didn't do any testing beyond that! :) )

      import oauth2
      import urllib
      import time
      import requests

      q = '1 Infinate Loop, Cupertino CA 95014'

      params = { 
          'oauth_version': "1.0",
          'oauth_nonce': oauth2.generate_nonce(),
          'oauth_timestamp': int(time.time()),
          'q': urllib.quote_plus(q),
          'flags': 'J' 
      }


      yboss_key = "<your yboss key>"
      yboss_secret = "<your yboss secret>"

      consumer = oauth2.Consumer(key=yboss_key, secret=yboss_secret)
      req = oauth2.Request(method="GET", url=url, parameters=params)
      signature_method = oauth2.SignatureMethod_HMAC_SHA1()

      req.sign_request( signature_method, consumer, None )
      response = requests.get( req.to_url() )

      # Newer versions of requests
      print response.json()

      # Older versions of requests have json as a parameter so you need (instead of the line above):
      #print response.json


      Output:
      {u'bossresponse': {u'placefinder': {u'count': u'1', u'start': u'0', u'request': u'flags=J&q=1%2BInfinate%2BLoop%2C%2BCupertino%2BCA%2B95014', u'results': [{u'neighborhood': u'', u'house': u'1', u'county': u'Santa Clara County', u'street': u'Infinite Loop', u'radius': u'400', u'quality': u'85', u'unit': u'', u'city': u'Cupertino', u'countrycode': u'US', u'woeid': u'12797509', u'xstreet': u'', u'line4': u'United States', u'line3': u'', u'line2': u'Cupertino, CA 95014-2083', u'line1': u'1 Infinite Loop', u'state': u'California', u'latitude': u'37.331741', u'hash': u'0B730171A22CFC09', u'unittype': u'', u'offsetlat': u'37.331772', u'statecode': u'CA', u'postal': u'95014-2083', u'name': u'', u'uzip': u'95014', u'country': u'United States', u'longitude': u'-122.030746', u'countycode': u'', u'offsetlon': u'-122.030418', u'woetype': u'11'}]}, u'responsecode': u'200'}}



      On Aug 29, 2013, at 11:04 AM, Vasu Nagendra <vasuki.nagendra@...>
       wrote:

       

      Can you provide a sample Chris. I was getting errors when I submitted full addresses even with the right urllib encoding 


      On Aug 29, 2013, at 10:01 AM, Chris Brown <chris.brown@...> wrote:

       

      I'm using it in Python with good results.  I've noticed is that if there are spaces in your location (like if it's a full address) you need to encode them as plus signs or the service will return errors. (even though requests will do hex encoding on its own. I pass the query though urllib.quote_plus().  (Though I'm using the "q" parameter to pass my query as opposed to "location" so I'm not sure if that makes a difference)


      Also if you want JSON the parameter is "flags":"J" rather than "format":"json"

      Hope that helps someone.

      On Aug 28, 2013, at 10:45 PM, jungleg_nyc <jorge@...> wrote:

       

      Putting here so that people searching can get it working:

      requirements:

      requests
      requests_oauthlib

      code:

      import requests
      from requests_oauthlib import OAuth1
      url = u'http://yboss.yahooapis.com/geo/placefinder'

      queryoauth = OAuth1(YAHOO_GEO_KEY, YAHOO_GEO_SECRET)
      response = requests.get(url, params={'location':'Philly'}, auth=queryoauth)

      response.text
      u'<?xml version="1.0" encoding="UTF-8"?><bossresponse responsecode="200"><placefinder start="0" count="1" request="location=Philly"><results><result><quality>40</quality><latitude>39.952271</latitude><longitude>-75.162369</longitude><offsetlat>39.952271</offsetlat><offsetlon>-75.162369</offsetlon><radius>19800</radius><name/><line1/><line2>Philadelphia, PA</line2><line3/><line4>United States</line4><house/><street/><xstreet/><unittype/><unit/><postal/><neighborhood/><city>Philadelphia</city><county>Philadelphia County</county><state>Pennsylvania</state><country>United States</country><countrycode>US</countrycode><statecode>PA</statecode><countycode/><uzip>19107</uzip><hash/><woeid>2471217</woeid><woetype>7</woetype></result></results></placefinder></bossresponse>'


      Chris Brown
      Technical Architect
      National Write Your Congressman
      214-466-2382




      Chris Brown
      Technical Architect
      National Write Your Congressman
      214-466-2382

    Your message has been successfully submitted and would be delivered to recipients shortly.