Skip to content

Commit

Permalink
UTF-8 Encoding of keyword parameter handled correctly.
Browse files Browse the repository at this point in the history
Updated README syntax errors in code examples.
  • Loading branch information
Chavez committed May 4, 2012
1 parent 8a08782 commit 39fb30a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -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" })

Expand All @@ -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" })

Expand All @@ -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" })

Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions al_papi/al_http.py
Expand Up @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -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",
Expand Down

0 comments on commit 39fb30a

Please sign in to comment.