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

Commit 2bf6a8a

Browse files
committed
Merge pull request #260 from BrandonBielicki/master
Added UpdateBackgroundImage method and added profile_link_color argument to UpdateProfile
2 parents cbae3e1 + cc8dffb commit 2bf6a8a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

twitter/api.py

Lines changed: 34 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.
@@ -3325,6 +3326,9 @@ def UpdateProfile(self,
33253326
description:
33263327
A description of the user owning the account.
33273328
Maximum of 160 characters. [Optional]
3329+
profile_link_color:
3330+
hex value of profile color theme. formated without '#' or '0x'. Ex: FF00FF
3331+
[Optional]
33283332
include_entities:
33293333
The entities node will be omitted when set to False.
33303334
[Optional]
@@ -3345,6 +3349,8 @@ def UpdateProfile(self,
33453349
data['location'] = location
33463350
if description:
33473351
data['description'] = description
3352+
if profile_link_color:
3353+
data['profile_link_color'] = profile_link_color
33483354
if include_entities:
33493355
data['include_entities'] = include_entities
33503356
if skip_status:
@@ -3354,6 +3360,34 @@ def UpdateProfile(self,
33543360
data = self._ParseAndCheckTwitter(json_data.content)
33553361

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

33583392
def UpdateImage(self,
33593393
image,

0 commit comments

Comments
 (0)