Hi there, I just recently started using the Twitter API and found the status posting endpoint was super easy to use with twurl. However, I’m now trying to update my profile banner using the POST account/update_profile_banner endpoint and it isn’t working nor giving useful errors (or anything) back. I was wondering if someone else had previously struggled with this or has any pointers on things I can try.

After successfully authorizing with:

twurl authorize --consumer-key KEY \
                --consumer-secret SECRET

I am now trying to run the following:

twurl -d 'banner=IMAGE_DATA' /1.1/account/update_profile_banner.json

where IMAGE_DATA is the Base64 encoded image. I previously had an issue with IMAGE_DATA being too large for bash to actually run, but have now fixed that. Now when I run the command it seems to execute correctly (the return code is 0 running from within Python). But there is nothing actually returned (no JSON response) and more importantly the profile banner remains unchanged.

If anyone is able to help in any way it would be greatly appreciated!

All the best,
Oisín

Using the -t option on the twurl command I get the following:

opening connection to api.twitter.com:443...
opened
starting SSL for api.twitter.com:443...
SSL established, protocol: TLSv1.2, cipher: ECDHE-RSA-AES128-GCM-SHA256
<- "POST /1.1/account/update_profile_banner.json HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: twurl version: 0.9.6 platform: ruby 2.6.3 (universal.x86_64-darwin19)\r\nContent-Type: application/x-www-form-urlencoded\r\nAuthorization: OAuth oauth_consumer_key=\"XXXXX\", oauth_nonce=\"XXXXX\", oauth_signature=\"XXXXX\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"11111\", oauth_token=\"11111-XXXXX\", oauth_version=\"1.0\"\r\nConnection: close\r\nHost: api.twitter.com\r\nContent-Length: 142033\r\n\r\n"
<- "banner=%2F9j%2F4AAQSkZJRgABAQAAAQABAAD%2F2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4n
... [TRUNCATED HERE FOR BREVITY] ...
U%2FhzRRTluAwmo9x9aKKkZ%2F9k%3D"
-> "HTTP/1.1 201 Created\r\n"
-> "cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0\r\n"
-> "connection: close\r\n"
-> "content-length: 0\r\n"
-> "content-security-policy: default-src 'self'; connect-src 'self'; font-src 'self' https://*.twimg.com https://twitter.com https://ton.twitter.com data:; frame-src 'self' https://*.twimg.com https://twitter.com https://ton.twitter.com; img-src 'self' https://*.twimg.com https://twitter.com https://ton.twitter.com data:; media-src 'self' https://*.twimg.com https://twitter.com https://ton.twitter.com; object-src 'none'; script-src 'self' https://*.twimg.com https://twitter.com https://ton.twitter.com; style-src 'self' https://*.twimg.com https://twitter.com https://ton.twitter.com; report-uri https://twitter.com/i/csp_report?a=OBZG6ZTJNRSWE2LSMQ%3D%3D%3D%3D%3D%3D&ro=false;\r\n"
-> "content-type: text/html;charset=utf-8\r\n"
-> "date: Sat, 03 Oct 2020 22:30:13 GMT\r\n"
-> "expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n"
-> "last-modified: Sat, 03 Oct 2020 22:30:13 GMT\r\n"
-> "pragma: no-cache\r\n"
-> "server: tsa_f\r\n"
-> "set-cookie: personalization_id=\"v1_XXXXX==\"; Max-Age=63072000; Expires=Mon, 03 Oct 2022 22:30:13 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None\r\n"
-> "set-cookie: lang=en; Path=/\r\n"
-> "set-cookie: guest_id=v1%11111; Max-Age=63072000; Expires=Mon, 03 Oct 2022 22:30:13 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None\r\n"
-> "status: 201 Created\r\n"
-> "strict-transport-security: max-age=631138519\r\n"
-> "vary: Origin\r\n"
-> "x-access-level: read-write\r\n"
-> "x-connection-hash: 84444a2727bdb121b356e347a22aefc7\r\n"
-> "x-frame-options: SAMEORIGIN\r\n"
-> "x-rate-limit-limit: 30\r\n"
-> "x-rate-limit-remaining: 27\r\n"
-> "x-rate-limit-reset: 1601765057\r\n"
-> "x-response-time: 624\r\n"
-> "x-transaction: 003063c1009077cc\r\n"
-> "x-tsa-request-body-time: 150\r\n"
-> "x-twitter-response-tags: BouncerCompliant\r\n"
-> "x-xss-protection: 1; mode=block\r\n"
-> "\r\n"
reading 0 bytes...
-> ""
read 0 bytes
Conn close

Ah! Silly me, it turns out it was posting to my other account! Seeing that some of the rate limit in the trace above made me suspect that I had done something right, then finding https:// github .com/twitter/twurl#changing-your-default-profile finally made it click.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.