Profile Banner support in the API

episod
@episod Taylor Singletary

Hi Developers,

I'm happy to announce that the upload method for the new profile banner feature is now available in API v1. API v1.1's profile banner upload feature will be available in the coming weeks.

As you probably have already noticed, you'll find a HTTPS-based "profile_banner_url" within v1 and v1.1 user objects belonging to users who have uploaded a profile banner. This URL can be easily manipulated to yield an image sized appropriately for your context: web, ipad, and mobile. Each of these representations also has a high-resolution "retina" variation. In the future, we'll have a method available that will denote these variant URLs so you don't need to munge them, but for now you can read more about profile banner variations.

POST account/update_profile_banner works similarly to profile background and avatar upload methods, with the additional ability to give us hints about the image's dimensions and how the user may want it offset. POST account/remove_profile_banner is used to remove an already uploaded profile banner. Both of these methods will be available in API v1.1 soon.

We're excited to see the programmatic profile design possibilities you'll build with these new profile banners.

49 weeks 13 hours ago

Replies

janole
@janole Jan Ole Suhr

Hi Taylor,

thanks for providing this API and writing up the docs :-) My users have been pretty excited about this profile banner ...

Just one question: I've seen that some accounts have a different profile banner url with the ending "/live" (like @AppStore.) What's that about?

@janole

49 weeks 11 hours ago
episod
@episod Taylor Singletary

Hi @janole!

What @AppStore has is techincally not a profile banner but a "enhanced profile page," which was part of our commercial offerings for advertisers. Most who had such a page have moved on to the improved profile banner, but not everyone has yet. You should see little to none of these in the coming weeks.

49 weeks 11 hours ago
OllieParsley
@OllieParsley Ollie Parsley

I'm trying to use the new endpoint and I'm getting the following response:
{"error":"Could not authenticate with OAuth.","request":"/1/account\/update_profile_banner.json"}

The documentation has two different endpoints:
* https://api.twitter.com/1/account/update_profile_banner.json
* https://api.twitter.com/1/account/profile_banner.json (this was listed as an example request on https://dev.twitter.com/docs/api/1/post/account/update_profile_banner)

I tried them both and substituted the "api" subdomain for "upload" just in case. The upload subdomain resulted in an HTML response and the other 2 had the oauth error. I also tried API version 1.1 and got the following response:
{"errors":[{"message":"Bad Authentication data","code":215}]}

FYI I'm using TheMattHarris' php library.

Thanks

Ollie

49 weeks 11 hours ago
episod
@episod Taylor Singletary

Sorry for the confusion, I've rectified the docs in this area -- the endpoint is indeed https://api.twitter.com/1/account/update_profile_banner.json

If you can share the code you're using to execute this, I can perhaps help you out.

Here is some example code using tmhOAuth and uploading from a file submitted via a web-based upload dialog.

  1.   // The end-user has uploaded the image on the previous page
  2.   $params = array(
  3.     'banner' => "@{$_FILES['image']['tmp_name']};type={$_FILES['image']['type']};filename={$_FILES['image']['name']}",
  4.   );
  5.  
  6.   // if we are setting the banner we want it to be displayed
  7.   $code = $tmhOAuth->request('POST', $tmhOAuth->url("1/account/update_profile_banner"),
  8.     $params,
  9.     true, // use auth
  10.     true  // multipart
  11.   );
  12.  
  13.   if ($code == 200) {
  14.     tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
  15.   }
  16.   tmhUtilities::pr(htmlentities($tmhOAuth->response['response']));

You will likely find it best to leverage multipart content-type.

49 weeks 11 hours ago
OllieParsley
@OllieParsley Ollie Parsley

Apologies, it was my bad! My code was virtually identical to yours. I didn't realise the oauth token and secret were null in the db record I was using. Doh! The other endpoint I tried (users/show) obviously didn't require auth, so it didn't complain when I'd send bad credentials.

Awesome that this API has been added though :)

Thanks

49 weeks 10 hours ago
sferik
@sferik Erik Michaels-Ober

Will profile_banner_url attributes always be an HTTPS URLs? It seems incongruous for profile_image_url to be an HTTP URL while profile_banner_url is an HTTPS URL. I understand why this might be inconsistent for backward compatibility in API v1 but it would be nice if it was made consistent in API v1.1.

49 weeks 7 hours ago
episod
@episod Taylor Singletary

As a service, we're moving to requiring SSL for more and more but we're not all the way there yet. If there's a point where there will be SSL URLs exclusively, it would likely be a future (more dramatically different) version 2 of the API rather than API v1.1. profile_banner_url will indeed always be SSL.

48 weeks 6 days ago
sferik
@sferik Erik Michaels-Ober

Also, the documentation for POST account/update_profile_banner says that it may return HTTP 422 if the image is too large, however 422 is not listed as a possible HTTP response code at https://dev.twitter.com/docs/error-codes-responses.

49 weeks 5 hours ago
episod
@episod Taylor Singletary

Will add that in, thanks.

48 weeks 6 days ago
sferik
@sferik Erik Michaels-Ober

Another incongruity between POST account/update_profile_image and POST account/update_profile_banner is that, on success, former returns a JSON user object, while the latter returns an empty body. It would be nicer of these two methods had a similar response.

48 weeks 6 days ago
episod
@episod Taylor Singletary

I would prefer that as well, I'll see if it's possible -- though the profile_banner_url returned in the response may not yet be available at the time of the response.

48 weeks 6 days ago
sferik
@sferik Erik Michaels-Ober

I believe that's also the case for POST account/update_profile_image and POST account/update_profile_background_image, but those always return a user object. It would be nice if POST account/update_profile_banner was consistent with these other resources.

43 weeks 1 day ago
episod
@episod Taylor Singletary

The profile banner upload and remove API is now available in API v1.1:
* POST account/update_profile_banner
* POST account/remove_profile_banner

Additionally, we've added a convenience method for those who are not fans of string manipulation:
* GET users/profile_banner

43 weeks 4 days ago
paresh9925
@paresh9925 Paresh Panchal

episod...how to get profile image ..? which we get in v1... that type url ..?

12 weeks 3 days ago
harrylover_1
@harrylover_1 harry_styles

I love it thank you

43 weeks 4 days ago
Tom_Cully
@Tom_Cully Thomas Cullinane

Hi, every time I try to use this I get 422 return code...I have tried uploading an image from my computer as well as from a url, regardless of image size or dimension I get the 422 error :( any ideas? I am using tmhoauth, posting to 1/account/update_profile_banner, with 'banner' as sole param

43 weeks 3 days ago
Tom_Cully
@Tom_Cully Thomas Cullinane

got it working, was handling the image path as a string rather than a file :)

43 weeks 3 days ago
anaknilaiblogge
@anaknilaiblogge anaknilai bloggers

Welcome to anaknilai bloggers group........

41 weeks 6 days ago
philnash
@philnash Phil Nash

Hi,

I'm having a tough time with this API call. I have oauth keys for a user and I'm trying to send the banner as a base64 encoded string, as the documentation says I can. I keep getting 502 Bad Gateway responses (in HTML, when I request json).

Is this API ok or does it have any health issues? Should my usage be ok?

I hope you can help

41 weeks 6 days ago
philnash
@philnash Phil Nash

I just discovered this (not very well named) thread talking about the same issue: https://dev.twitter.com/discussions/11025

Is there anything that can be done about this?

41 weeks 5 days ago
chandan604
@chandan604 Chandan Singh

hi can any body tell me how I can connect to Twitter API using JAVA and pass parameter.

41 weeks 1 day ago
grillermo
@grillermo Guillermo Siliceo

This api method is broken, i tried with several twitter python libraries(the Twitter recommended ones included) and they all sent internal error, i even tried with the curl command twitter gives you and it fails.

24 weeks 5 days ago
kishore_nipuna
@kishore_nipuna kishore

hi, i am trying to update profile banner using api v 1.1 but it returns {"errors":[{"message":"Internal error","code":131}]}

i have submit base64 encodec banner image , width, height, offset_top, offset_left and access tokens

let me know what was the error here i dont understand what is "Internal error"

9 weeks 4 days ago