Skip to content

Commit

Permalink
Fixed erros with accents in media items or url
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbenfica committed Mar 7, 2017
1 parent 53995bb commit f64c309
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions buffpy/managers/updates.py
@@ -1,4 +1,5 @@
from buffpy.models.update import Update
import urllib

PATHS = {
'GET_PENDING': 'profiles/%s/updates/pending.json',
Expand Down Expand Up @@ -105,8 +106,8 @@ def new(self, text, shorten=None, now=None, top=None, media=None, when=None):
'''

url = PATHS['CREATE']

post_data = "text=%s&" % text
post_data = "text=%s&" % urllib.quote(text.encode("utf-8"))
post_data += "profile_ids[]=%s&" % self.profile_id

if shorten:
Expand All @@ -125,7 +126,7 @@ def new(self, text, shorten=None, now=None, top=None, media=None, when=None):
media_format = "media[%s]=%s&"

for media_type, media_item in media.iteritems():
post_data += media_format % (media_type, media_item)
post_data += media_format % (media_type, urllib.quote(media_item.encode("utf-8")))

response = self.api.post(url=url, data=post_data)
new_update = Update(api=self.api, raw_response=response['updates'][0])
Expand Down

0 comments on commit f64c309

Please sign in to comment.