请帮助我,我在使用 api v1.1 将图像上传到 Twitter 时遇到问题,一个月前它运行良好,但现在无法运行。我正在使用 Abraham twitteroauth https://github.com/abraham/twitteroauth 并且我使用 enctype="multipart/form-data" 作为表单标签中的属性,这是我的代码:
require 'inc/twitter.class.php';
if(!empty($_FILES['media']['name'])){ // tweet with media
$file_name = $_FILES['media']['name'];
$file_type = $_FILES['media']['type'];
$file_size = $_FILES['media']['size'];
$file_temp = $_FILES['media']['tmp_name'];
$file_error = $_FILES['media']['error'];
$handle = fopen($file_temp,'rb');
$image = fread($handle,filesize($file_temp));
fclose($handle);
$tweet = new TwitterOAuth($YOUR_CONSUMER_KEY, $YOUR_CONSUMER_SECRET, $row_user_info['access_token_oauth_token'], $row_user_info['access_token_oauth_token_secret']);
$result = $tweet->post('statuses/update_with_media',array('media[]' => "@{$image};type={$file_type};filename={$file_temp}",'status' => 'test'));
echo '<pre>';
print_r($result);
echo '</pre>';
结果是:
stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[code] => 195
[message] => Missing or invalid url parameter.
)
)
)
我不知道其中缺少什么,请帮助我