So far I have been trying to update the twitter profile bg image thr the twitter api with php... and without success
Many examples on the web, including this one:
I think you're using the CURLOPT_POSTFIELDS method wrong. You need to put and @ sign in front of the full path to the file according to the documentation for curl PHP. You are not supposed to output the whole file contents.
The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. This can either be passed as a urlencoded string like 'para1=val1¶2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data.
This is an example from the documentation.
'Foo', 'file' => '@/home/user/test.png');
curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
?>
I hope this helps.