Change Background image using Twitter API
I was playing with the twitter API and i found that they allow to change the background image and color scheme using API . So i tried to change those using php.
For this test i used the cURL and php . Here is the code
<?php
set_time_limit(0);
$twitterUser = $_REQUEST['username'] ;
$twitterPass = $_REQUEST['password'] ;
$link = "http://twitter.com/account/update_profile_background_image.xml"; // The URL to change the background image
$params = array(
"image"=>"@$fullfilepath",
"tile"=> $tile);
//$fullfilepath is NOT the http:// path , this is the file location . Its like /home/tmp/test.jpg . But if you want to use any file from the web you need to make a copy of that file in the server then use that .
// Tile is boolean , if you want to set the background tile then this should be 'true' , it took few minutes of me because i tried with 1 , then true but it needs string true so that is 'true' or "true" .
twitter($link,$params); // Make the call with the parameters
function twitter($link,$params){
global $twitterUser; // This is the username
global $twitterPass; // Password of the user
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:')); // Without the header you'll get 100 Error
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_USERPWD, "$twitterUser:$twitterPass");
$resp = curl_exec($curl);
curl_close($curl);
return $resp;
}
Thats it. Have fun.











nice work…keep going.
thanks dude, I really need that.
Doesn’t work for me. =( Keeps sayin “Fatal error: Call to undefined function twitter()”
check ur twitter function .
another copy and paste tutorial.. this script is not working..
account/update_profile_background_image is not functional until now..
@Marvin where do u live ? In earth its working nicely and if this tutorial copy & paste , can u tell me the original source ? I think that is ur site right ?
So why they fuck u are reading my post ? Just fuck off .
Hi,
Thanks for the info. I a currently working on a small project for one of my sites and am looking for a way of letting people change their twitter backgrounds using oAuth.Will the code you have above allow me to do that on a wordpress site?
@Gerri
Its it can be implemented with the oAuth , but u need to save the token and token secret on ur database to init one use users session .
This script was using the basic auth and as that is already deprecated u cant just copy and paste the code .
I know nothing about php scripts or twitter api’s but I was wondering can this be implemented on a blog? If so how?If not how do I implement this in a website, do I just add the script and that’s it?
Hi,
can u just help me out,actually i have done twitter background change by using oauth , and it’s working fine but sometimes it’s just giving me fatal errors why……….
Sorry dont have any idea
super website