我想發佈描述和圖像使用twitter API或JavaScript,所以什麼代碼...請幫助或任何解決方案。如何使用API或JavaScript在twitter上發佈推文(描述和圖像)
我使用下面的代碼。
include('tmhOAuth.php');
include('tmhUtilities.php');
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => '2gfF75xRSwnJDgfuwXBUGj59kA',
'consumer_secret' => 'snGgVlYdVfgOeTVl8aQYG5BQRyEbgxqfgu9B9zTpRomIUh58',
'user_token' => '148xf1479562-RYq76XIfgogfhjttdu0kLlWwQwEfgEM8wlRDMX44rUFPP',
'user_secret' => 'I7saxfu751zzMnWChgffA0VAiRQIdf2JFwTMLragf6MK4aF8pjbg',
));
$image = 'Chrysanthemum.jpg';
$code = $tmhOAuth->request('POST', 'https://upload.twitter.com/1/statuses/update_with_media.json',
array(
'media[]' => "@{$image}",
"status" => "Is this working now?"
),
true, // use auth
true // multipart
);
if ($code == 200) {
tmhUtilities::pr(json_decode($tmhOAuth->response['response']));
} else {
tmhUtilities::pr($tmhOAuth->response['response']);
}
但是,我有這個錯誤: JSON響應:
{
errors: [
{
message: "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.",
code: 68
}
]
}
什麼不清楚關於那個錯誤信息? – Quentin
我想你應該使用1.1 API https://dev.twitter.com/blog/api-v1-is-retired – AntouanK