1

当我尝试使用 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);
4

0 回答 0