here is my php code :
<?php
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $consumerKey,
'consumer_secret' => $consumerSecret,
'user_token' => $oAuthToken,
'user_secret' => $oAuthSecret,
));
function tweet_get_id($image, $stutase){
global $tmhOAuth;
$code = $tmhOAuth->request(
'POST',
'http://upload.twitter.com/1/statuses/update_with_media.json',
array(
"media[]" => "@{$image} ",
"status" => $stutase,
),
true, // use auth
true // multipart
);
if($code == 200){
$json = json_decode($tmhOAuth->response['response']);
if($_SERVER['HTTPS'] == "on") {
$image_url = $json->entities->media[0]->media_url_https;
}else{
$image_url = $json->entities->media[0]->media_url;
}
$text = $json->text;
$id_str = $json->id_str;
$content = "
Upload success. Image posted to Twitter.
![]()
". $text . "
". $id_str . "
";
return true;
return $id_str;
}else{
echo $content = "Damn! Something went wrong. Sorry :-("
."
code=" . $code
."
status=" . $stutase
."
image=" . $image
."
response=
"
. print_r($tmhOAuth->response['response'], TRUE)
. " info=
"
. print_r($tmhOAuth->response['info'], TRUE)
. " code=
"
. print_r($tmhOAuth->response['code'], TRUE) . ""
. print_r($tmhOAuth->response, TRUE) . "
";
return false;
}