当我尝试使用php curl在twitpic上传图像时,图片无法上传,响应是最后一个json,其中包含有关手动上传图片的数据。
$access_token = $twitteroauth->getAccessToken($this->input->get('oauth_verifier'));
$post['consumer_token'] = "my_consumer_token";
$post['consumer_secret'] = "My_consumer_secret";
$post['oauth_token'] = $access_token['oauth_token'];
$post['oauth_secret'] = $access_token['oauth_token_secret'];
$post['key'] = "my_twitpic_api_key";
$post['message'] = "123";
$post['media'] = "@".$_SERVER['DOCUMENT_ROOT']."/upload/sharing/pic_1334141805.PNG";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://api.twitpic.com/1/uploadAndPost.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
if(!$result){
$result = curl_error($ch);
}
curl_close($ch);