Hi,
I’m trying to implement https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media. I try to do it in javascrip and didn’t work then I try to do it in php and send me an error 403.
This is my php code:
<?php
require 'control/tmhOAuth.php';
require 'control/tmhUtilities.php';
$consumer_key = $_POST['consumer_key'];
$consumer_secret = $_POST['consumer_secret'];
$user_token = $_POST['user_token'];
$user_secret = $_POST['user_secret'];
$mensaje = urlencode($_POST["mensaje"]);
$img = $_POST['img'];
$imgbinary = fread(fopen('imgConMarco/' . $img, "r"), filesize('imgConMarco/' . $img));
$img = base64_encode($imgbinary);
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $consumer_key,
'consumer_secret' => $consumer_secret,
'user_token' => $user_token,
'user_secret' => $user_secret,
'curl_ssl_verifypeer' => false,
'multipart' => true
));
$response = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update_with_media'),
array(
'status' => $mensaje,
'media[]' => $img
),
true,
true
);
echo realpath('imgConMarco/' . $img) . " --->> ";
echo "respuesta: " . var_dump($response) . " --- ";
print_r($response);
if ($response != 200) {
//Do something if the request was unsuccessful
//echo "false";
tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
}else{
//echo "true";
tmhUtilities::pr($tmhOAuth->response['response']);
}
this code send me the error:
403
stdClass Object\n(\n [errors] => Array\n (\n [0] => stdClass Object\n (\n [code] => 189\n [message] => Error creating status.\n )\n\n )\n\n)\n
"
Can you say me how to correct my problem? An example would help. thanks