File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ require "base64"
2+ require "uri"
3+ require "x"
4+
5+ x_credentials = {
6+ api_key : "INSERT YOUR X API KEY HERE" ,
7+ api_key_secret : "INSERT YOUR X API KEY SECRET HERE" ,
8+ access_token : "INSERT YOUR X ACCESS TOKEN HERE" ,
9+ access_token_secret : "INSERT YOUR X ACCESS TOKEN SECRET HERE"
10+ }
11+
12+ client = X ::Client . new ( base_url : "https://api.twitter.com/1.1/" , **x_credentials )
13+
14+ avatar_path = "path/to/avatar.jpg"
15+ avatar_data = Base64 . encode64 ( File . binread ( avatar_path ) )
16+ avatar_body = URI . encode_www_form ( image : avatar_data )
17+ client . post ( "account/update_profile_image.json" , avatar_body , headers : { "Content-Type" => "application/x-www-form-urlencoded" } )
18+
19+ banner_path = "path/to/banner.jpg"
20+ banner_data = Base64 . encode64 ( File . binread ( banner_path ) )
21+ banner_body = URI . encode_www_form ( banner : banner_data )
22+ client . post ( "account/update_profile_banner.json" , banner_body , headers : { "Content-Type" => "application/x-www-form-urlencoded" } )
You can’t perform that action at this time.
0 commit comments