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

Re: [ysearchboss] Adding Placefinder to an existing Boss Search project

Expand Messages
  • Chris Brown
    Well it s definitely not a problem with my key because that works great with my secret and key. I did have to change format : json to flags : J though
    Message 1 of 10 , Apr 23, 2013
    • 0 Attachment
      Well it's definitely not a problem with my key because that works great with my secret and key. I did have to change "format": "json" to "flags" : "J" though to get JSON.

      Thanks for giving me something to go on. Now I just have to figure out what I'm doing wrong.

      Thanks,
      Chris

      On Apr 23, 2013, at 2:21 PM, Rahul Hampole <rhampole@...>
       wrote:

       

      Hi Chris
      I used this library  https://github.com/simplegeo/python-oauth2 and here is my code snippet. I am new to Python so forgive the code quality :-). 

      import oauth2 as oauth

      import time

      import urllib, urllib2


      def get_response(buckets,params):

          url =  "http://yboss.yahooapis.com/geo/" + buckets

          cc_key = "ENTER KEY HERE"

          cc_secret = "ENTER SECRET HERE"

          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': 'json',

      }

       

      print get_response(buckets,params)

      From: Rahul <rhampole@...>
      Reply-To: "ysearchboss@yahoogroups.com" <ysearchboss@yahoogroups.com>
      Date: Monday, April 22, 2013 9:56 AM
      To: "ysearchboss@yahoogroups.com" <ysearchboss@yahoogroups.com>
      Subject: Re: [ysearchboss] Adding Placefinder to an existing Boss Search project

       

      Hi Chris
      Thanks for this. Let me play around with it today and get back to you. Maybe I can give you a full code sample as well to make things easier!! 

      Thanks
      Rahul


      From: Chris Brown <chris.brown@...>
      Reply-To: "ysearchboss@yahoogroups.com" <ysearchboss@yahoogroups.com>
      Date: Monday, April 22, 2013 8:24 AM
      To: "<ysearchboss@yahoogroups.com>" <ysearchboss@yahoogroups.com>
      Subject: Re: [ysearchboss] Adding Placefinder to an existing Boss Search project

       
      Rahul,

      Sorry for the late reply. I think I replied to the wrong thread last week.  Thanks so much for your help on this. Here's the URL I'm using:


      Here's the code (python). It's a work in progress because I w! ant to add some other options and right now I'm not handling errors very well. References to "oauth" refer to the python "oauth2" library that's imported in this class. "config" is a module where my key and secret are defined. The exact same setup is used to do searching in another function in the same module and it works with the key and secret I'm providing.


      def placefinder(self, **kwargs):
              consumer = oauth.Consumer(key=config.yboss_key,secret=config.yboss_secret)
          
              
               params = { 
                  'oauth_nonce': oauth.generate_nonce(),
         ! ;         'oauth_timestamp': int(time.time()),
                  'oauth_version': "1.0",
                  'flags': "J",
                  'q': kwargs.get('q'),
                   'appid': "my_app_id"
              }   

              req = oauth.Request(method="GET",url=url,parameters=params)
              signature_method = oauth.SignatureMethod_HMAC_SHA1()
              req.sign_request(signature_method,consumer,None)

              f = urllib.urlopen(req.to_url())
              retval = json.load(f)

              response = retval.get('bossresponse')

              if response and respons! e.get('responsecode') == "200" and response.get('placefinder'):
                  pl = response.get('placefinder')
                  if pl.get('count') > 0:
                      result = pl.get('results')[0]

                      return (result.get('latitude'), result.get('longitude') )
                  else:
                      raise GeoCodeError("No results found")
              else:
                  if response:
                      msg = "Invalid response: " + str(response.get('responsecode'))
                  else:
            &! nbsp;         msg = "No response from YBOSS Geocoder"

                  raise GeoCodeError(msg)


      Also I get XML back in the error rather than JSON even though I have "flags":"J" so I'm assuming I'm doing something wrong there. This is what I get back:

      401 Unauthorized
      <yahoo:error xml:lang="en-US" xmlns:yahoo="http://yahooapis.com/v1/base.rng">
      <yahoo:description>
      Please provid! e valid credentials. OAuth oauth_problem="signature_invalid", realm="yahooapis.com"
      </yahoo:description>
      </yahoo:error>

      Thanks,
      Chris



      On Apr 17, 2013, at 12:13 PM, Rahul Hampole <rhampole@...> wrote:

       

      Hi Chris
      Can you provide the sample URL you are calling and a code snippet here (your an remove the oAuth parameters)

      Thanks
      BOSS Team


      From: Chris Brown <chris.brown@...>
      Reply-To: "ysearchboss@yahoogroups.com" <ysearchboss@yahoogroups.com>
      Date: Tuesday, April 16, 2013 5:16 PM
      To: "<ysearchboss@yahoogroups.com>" <ysearchboss@yahoogroups.com>
      Subject: Re: [ysearchboss] Re: Adding Placefinder to an existing Boss Search project

       
      I used the same code that's working for search to create the Oauth request (including the same credentials) but when I do it returns 401 Unauthorized.   

      Thanks

      On Apr 16, 2013, at 3:52 PM, Rahul Hampole <rhampole@...>
       wrote:

       

      You can use the exact same keys to query Placefinder without signing up again. 

      Your call would be something like this

      http://yboss.yahooapis.com/geo/placefinder?q=Sunnyvale (oAuth parameters not included). 

      Make sure to encode '+' to %20. 

      Let me know if anything else
      Regards
      BOSS Team


      From: firemodules <bcollins@...>
      Reply-To: "ysearchboss@yahoogroups.com" <ysearchboss@yahoogroups.com>
      Date: Tuesday, April 16, 2013 1:10 PM
      To: "ysearchboss@yahoogroups.com" <ysearchboss@yahoogroups.com>
      Subject: [ysearchboss] Re: Adding Placefinder to an existing Boss Search project

       
      It certainly should be possible.In the project page, do you have an option to check GEO as a possible API to use?

      __________________________________________________________
      **Note: The BOSS API and BOSS Geo offerings, being API's share a common authentication system and hence keys can be shared across both services seamlessly.
      __________________________________________________________

      --- In ysearchboss@yahoogroups.com, "nwycdeveloper" <chris.brown@...> wrote:
      >
      > I apologize if this is answered somewhere but I can't seem to find it in the documentation or by searching.
      >
      > We have an existing project that uses News search and it's working great. I'd now like to add placefinder functionality to the same project. I was hoping that my existing credentials would work but it seems they are not. I get 401 unauthorized when I try to access placefinder.
      >
      > Is there anyway to add Placefinder capability to the existing project?
      >










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