Hi everyone, I'm trying to upload profile_image with php. And it seems i have uploaded the image successfully and got the response, but the image which I've just uploaded was not shown on the web.
Here are the codes and responses: -------------------------------------------------------------------------------- --- The php code: -------------------------------------------------------------------------------- <?php function twitter_process($url, $post_data = false) { if ($post_data === true) $post_data = array(); $ch = curl_init($url); if($post_data !== false) { curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $post_data); } curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:', 'X-Twitter-Client: ','X-Twitter-Client-Version: ','X-Twitter-Client-URL: ')); curl_setopt($ch, CURLOPT_USERPWD, 'cnalpha:password');//for testing curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'testing api'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); echo $response = curl_exec($ch); $response_info=curl_getinfo($ch); curl_close($ch); } $file = 'ninja-heart.png'; $url = 'https://twitter.com/account/update_profile_image.xml'; $fields['image'] = '@'.realpath($file); twitter_process($url,$fields); ?> -------------------------------------------------------------------------------- --- The response I've got: -------------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <user> <id>55821366</id> <name>cnAlpha!</name> <screen_name>cnAlpha</screen_name> <location>location test</location> <description>testing bio</description> <profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/ninja-heart_normal.png</profile_image_url> <url>http://localhost/fake/</url> <protected>false</protected> <followers_count>5</followers_count> <profile_background_color>9AE4E8</profile_background_color> <profile_text_color>333333</profile_text_color> <profile_link_color>0084B4</profile_link_color> <profile_sidebar_fill_color>DDFFCC</profile_sidebar_fill_color> <profile_sidebar_border_color>BDDCAD</profile_sidebar_border_color> <friends_count>28</friends_count> <created_at>Sat Jul 11 12:33:05 +0000 2009</created_at> <favourites_count>0</favourites_count> <utc_offset>28800</utc_offset> <time_zone>Beijing</time_zone> <profile_background_image_url>http://static.twitter.com/images/themes/theme1/bg.gif</profile_background_image_url> <profile_background_tile>false</profile_background_tile> <statuses_count>10</statuses_count> <notifications>false</notifications> <verified>false</verified> <following>false</following> <status> <created_at>Mon Jul 27 08:49:08 +0000 2009</created_at> <id>2867594331</id> <text>测试程序</text> <source>web</source> <truncated>false</truncated> <in_reply_to_status_id></in_reply_to_status_id> <in_reply_to_user_id></in_reply_to_user_id> <favorited>false</favorited> <in_reply_to_screen_name></in_reply_to_screen_name> </status> </user> -------------------------------------------------------------------------------- --- Then I opened https://twitter.com/cnalpha and I found the picture was not shown. --- So, I opended http://s3.amazonaws.com/twitter_production/profile_images/ninja-heart_normal.png, --- the url of the picture and I got errors: -------------------------------------------------------------------------------- <Error> <Code>NoSuchKey</Code> <Message>The specified key does not exist.</Message> <Key>profile_images/ninja-heart_normal.png</Key> <RequestId>9F59BC459B56D618</RequestId> <HostId> syUrwNpASUBd0bQA0CLb29GcTnQD4Al7Ors7cnv5zrltqFD5ImeI2W0Prqlj2V2v </HostId> </Error> So, how can I upload a profile_image with php? Forgive my poor English Darasion.