1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <?php
/**
* Envoie un message sur twitter (stat
* Si le message, une fois encodé en UTF-8, fait plus de 140 caractères, alors il ne sera pas accepté par Twitter.
*
* @param $message Message à envoyer à Twitter
* @return TRUE ou FALSE
*/
$message = 'Script php pour twitter';
echo $message;
function tweet($message) {
require 'tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => 'ma_clef_consumer',
'consumer_secret' => 'ma_clef_consumer_secret',
'user_token' => 'ma_clef_acess_token',
'user_secret' => 'ma_clef_access_secret_token',
));
$tmhOAuth->request('POST', $tmhOAuth->url('statuses/update'), array(
'status' => utf8_encode($message)
));
if ($tmhOAuth->response['code'] == 200) {
// En cours de dév, afficher les informations retournées :
// $tmhOAuth->pr(json_decode($tmhOAuth->response['response']));
echo "TRUE";
return TRUE;
} else {
// En cours de dév, afficher les informations retournées :
// $tmhOAuth->pr(htmlentities($tmhOAuth->response['response']));
echo "FALSE";
return FALSE;
}
}
tweet();
?> |