I am trying to implement PayPal IPN functionality. The basic protocol is as such:
Try converting the params dictionary to utf-8 first... urlencode seems to like that better than unicode:
params = urllib.urlencode(dict([k, v.encode('utf-8')] for k, v in params.items()))
Of course, this assumes your input is unicode. If your input is something other than unicode, you'll want to decode it to unicode first, then encode it:
params['foo'] = my_raw_input.decode('iso-8859-1')
params = urllib.urlencode(dict([k, v.encode('utf-8')] for k, v in params.items()))