Twitter oauth 使用twitter API发布图像时缺少url参数或url参数无效

Twitter oauth 使用twitter API发布图像时缺少url参数或url参数无效,twitter-oauth,Twitter Oauth,我试图在twitter上发布图片。映像已在我的服务器中。这是我的密码 $tweet_img = '/home/voucherscode/public_html/editsocial/'.$tweet_img; $returnT = $connection->post('statuses/update_with_media', array( 'media[]' => file_get_contents($tweet_img), 'status' => "$tw

我试图在twitter上发布图片。映像已在我的服务器中。这是我的密码

$tweet_img = '/home/voucherscode/public_html/editsocial/'.$tweet_img;
$returnT = $connection->post('statuses/update_with_media', array(
     'media[]' => file_get_contents($tweet_img),
     'status' => "$tweet_msg" 
 ));
但我的回答是

stdClass Object(
[errors] => Array
    (
        [0] => stdClass Object
            (
                [code] => 195
                [message] => Missing or invalid url parameter.
            )
    ))

请帮忙。

我明白了。我使用的是旧的twitteroauth,在这个post函数中没有multipart参数

我用替换了我的twitteroauth,它可以用下面的代码工作

$tweet_img = '/home/voucherscode/public_html/editsocial/'.$tweet_img;

$handle = fopen($tweet_img,'rb');
$image = fread($handle,filesize($tweet_img));
fclose($handle);

$parameters = array('media[]' => "{$image};type=image/jpeg;filename={$tweet_img}",'status' => 'Picture time');



$returnT = $connection->post('statuses/update_with_media', $parameters, true);

提及您正在使用的库。我使用了tomi heiskanen的固定twitter oauth API。我尝试了此解决方案,但仍然显示缺少或无效的url参数,这对我不起作用。