API de Twitter -> actualizando la imagen de perfil bg con php

Hasta ahora he estado tratando de actualizar el perfil de twitter bg image thru api con php ... y sin éxito

Muchos ejemplos en la web, incluido este:
Actualización de fondo de Twitter a través de API
y éste
Carga en segundo plano de Twitter con API y datos de formularios múltiples
No funciona en absoluto, la mayoría de las personas lanzan respuestas sin probar realmente el código.

Descubrí que enviar directamente la imagen al formulario html de twitter.com, funcionará:

<form action="http://twitter.com/account/update_profile_background_image.xml" enctype="multipart/form-data" method="post">
    File: <input type="file" name="image" /><br/>
    <input type="submit" value="upload bg">
</form>

(aunque el navegador le pedirá el nombre de usuario y la contraseña de la cuenta de Twitter)

Sin embargo, si quiero pasar por el mismo proceso con php, falla

<?php
if( isset($_POST["submit"]) ) {

    $target_path = "";
    $target_path = $target_path . basename( $_FILES['myfile']['name']); 

    if(move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
        // "The file ".  basename( $_FILES['myfile']['name']). " has been uploaded<br/>";
    } else{
        // "There was an error uploading the file, please try again!<br/>";
    }

    $ch = curl_init('http://twitter.com/account/update_profile_background_image.xml');
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($ch, CURLOPT_USERPWD, $_POST['name'] . ':' . $_POST['pass']);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
    curl_setopt($ch, CURLOPT_TIMEOUT, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array('image' => base64_encode(file_get_contents($target_path))));

    $rsp = curl_exec($ch);
    echo "<pre>" . str_replace("<", "&lt;", $rsp) . "</pre>";

}
?>
<form enctype="multipart/form-data" method="post">
<input type="hidden" name="submit" value="1"/>
name:<input type="text" name="name" value=""/><br/>
pass:<input type="password" name="pass" value=""/><br/>
File: <input type="file" name="myfile" /><br/>
<input type="submit" value="upload bg">
</form>

Lo extraño de este código es que ... devuelve con éxito el XML de Twitter,SIN Tener la imagen de fondo del perfil actualizada. Así que al final todavía falla.

Muchas gracias por leer esto. Será genial si puedes ayudar. Por favor, prueba tu código primero antes de tirar las respuestas, muchas gracias.

Respuestas a la pregunta(4)

Su respuesta a la pregunta