val = urllib.parse.quote(val, '')
return urllib.parse.quote(key + '=' + val, '')

def signature_base_string(urlstr, oauthdata):
    sigstr = 'POST&' + urllib.parse.quote(urlstr, '') + '&'
pdata = oauthdata.getpdata()
pstr = '%26'.join([encodekeyval(key, pdata[key]) for key in sorted(pdata.
    keys())])
return sigstr + pstr
Getting 401 on Twitter OAuth POST requests