Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit 31fc699

Browse files
Added UpdateBackgroundImage method. UpdateProfile now accepts profile_link_color parameter
1 parent cbae3e1 commit 31fc699

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

twitter/api.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,7 @@ def UpdateProfile(self,
33043304
profileURL=None,
33053305
location=None,
33063306
description=None,
3307+
profile_link_color=None,
33073308
include_entities=False,
33083309
skip_status=False):
33093310
"""Update's the authenticated user's profile data.
@@ -3345,6 +3346,8 @@ def UpdateProfile(self,
33453346
data['location'] = location
33463347
if description:
33473348
data['description'] = description
3349+
if profile_link_color:
3350+
data['profile_link_color'] = profile_link_color
33483351
if include_entities:
33493352
data['include_entities'] = include_entities
33503353
if skip_status:
@@ -3354,6 +3357,34 @@ def UpdateProfile(self,
33543357
data = self._ParseAndCheckTwitter(json_data.content)
33553358

33563359
return User.NewFromJsonDict(data)
3360+
3361+
def UpdateBackgroundImage(self,
3362+
image,
3363+
tile=False,
3364+
include_entities=False,
3365+
skip_status=False):
3366+
3367+
url = '%s/account/update_profile_background_image.json' % (self.base_url)
3368+
with open(image, 'rb') as image_file:
3369+
encoded_image = base64.b64encode(image_file.read())
3370+
data = {
3371+
'image': encoded_image
3372+
}
3373+
if tile:
3374+
data['tile'] = 1
3375+
if include_entities:
3376+
data['include_entities'] = 1
3377+
if skip_status:
3378+
data['skip_status'] = 1
3379+
3380+
json = self._RequestUrl(url, 'POST', data=data)
3381+
if json.status_code in [200, 201, 202]:
3382+
return True
3383+
if json.status_code == 400:
3384+
raise TwitterError({'message': "Image data could not be processed"})
3385+
if json.status_code == 422:
3386+
raise TwitterError({'message': "The image could not be resized or is too large."})
3387+
33573388

33583389
def UpdateImage(self,
33593390
image,

0 commit comments

Comments
 (0)