iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IAAAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1JREFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jqch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0vr4MkhoXe0rZigAAAABJRU5ErkJggg==
The above data is a picture in data:image/png;base64
format. Is it possible to update a twitter profile picture without providing the path to the image (like http://....com ) but instead by providing the image data in the format above?
Yes, it's documented https://dev.twitter.com/rest/reference/post/account/update_profile_image and https://dev.twitter.com/rest/reference/post/account/update_profile_background_image
Sending something via base64_encode(file_get_contents($image_path))))
will yield results. Make sure your file is <700kb and smaller than <1000px.
Having had a quick look at the Twitter Documentation, specifically the section regarding Updating a User's Profile Image , it does not clearly state whether it will, or will not accept a Base64-encoded string for an image.
That being said, I would presume that it would not (feel free to test it and see if it does, but, as a rule, if an API wants a URL as an input, it will only recognise a URL as valid).
You could, of course, create a PHP script on your server, which, using the PHP function imagecreatefromstring()
[ PHP Docs ] and then use that URI as the value for the Twitter API.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.