Permalink
Browse files

UTF-8 Encoding of keyword parameter handled correctly.

Updated README syntax errors in code examples.
  • Loading branch information...
1 parent 8a08782 commit 39fb30a373fddd123ae2f17d16766103ece36e04 Chavez committed May 4, 2012
Showing with 10 additions and 7 deletions.
  1. +6 −6 README.md
  2. +3 −0 al_papi/al_http.py
  3. +1 −1 setup.py
View
@@ -16,15 +16,15 @@ Configure your api key to be used to make requests:
import al_papi
- al_papi.Config('yR43BtRDjadfavXy6a4aK3')
+ al_papi.Config.setup('yR43BtRDjadfavXy6a4aK3')
### POST
Post your keyword-engine-locale combination to the API once you have set your API key:
import al_papi
- al_papi.Config('yR43BtRDjadfavXy6a4aK3')
+ al_papi.Config.setup('yR43BtRDjadfavXy6a4aK3')
res = al_papi.Request.post({ "keyword" : "Centaur Stampede", "engine" : "bing", "locale" : "en-us" })
@@ -39,7 +39,7 @@ Post your keyword to the priority queue if you need results in a more timely man
import al_papi
- al_papi.Config('yR43BtRDjadfavXy6a4aK3')
+ al_papi.Config.setup('yR43BtRDjadfavXy6a4aK3')
res = al_papi.Request.priority_post({ "keyword" : "Druggie Scientist", "engine" : "bing", "locale" : "en-us" })
@@ -54,7 +54,7 @@ When you are ready to get your results you can do a GET request for your keyword
import al_papi
- al_papi.Config('yR43BtRDjadfavXy6a4aK3')
+ al_papi.Config.setup('yR43BtRDjadfavXy6a4aK3')
res = al_papi.Request.priority_post({ "keyword" : "Canadian Wizards", "engine" : "bing", "locale" : "en-us" })
@@ -70,15 +70,15 @@ When making an API request a response object is returned with any errors, http r
import al_papi
- al_papi.Config('yR43BtRDjadfavXy6a4aK3')
+ al_papi.Config.setup('yR43BtRDjadfavXy6a4aK3')
res = al_papi.Request.priority_post({ "keyword" : "Canadian Wizards", "engine" : "bing", "locale" : "en-us" })
# Errors:
# Returns an array of error objects.
res.errors
- for err in res.errors
+ for err in res.errors:
print err.message
print err.code
View
@@ -46,6 +46,9 @@ def request(verb, params, path):
http = Http()
params.update( { "auth_token" : al_papi.Config.api_key } )
+ keyword = params.get("keyword", "")
+ keyword = unicode(keyword, 'utf-8')
+ params.update( { "keyword" : keyword.encode('utf-8') })
url = '%s%s?%s' % ( al_papi.Config.default_host, path, urlencode(params) )
resp, content = http.request(url, verb, headers=al_papi.AlHttp.default_headers())
View
@@ -2,7 +2,7 @@
from distutils.core import setup
setup(
name="al_papi",
- version="0.0.3",
+ version="0.0.4",
description="AuthorityLabs Partner API Wrapper",
author="Chavez",
author_email="support@authoritylabs.com",

0 comments on commit 39fb30a

Please sign in to comment.