tmhOauth twitter api停止使用update_with_media调用

时间:2013-06-12 08:25:48

标签: twitter

所以,今天早上我收到了以下错误:

{"errors": [{"message": "The Twitter REST API v1 will soon stop functioning. 
Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.",
"code": 68}]}

由于我使用的是tmhOauth twitter api,我去查看是否有更新,因为似乎列出了here的问题。

我正在使用api用这样的媒体更新状态:

$code = $tmhOAuth->request('POST', 'https://upload.twitter.com/1/statuses/update_with_media.json',
        array(
            'media[]'  => "@{$image}",
            'status'   => "{$text}"
        ),
        true, // use auth
        true  // multipart
);

我发现我应该更改链接以使用1.1代替1,但它仍然无效。

2 个答案:

答案 0 :(得分:4)

我的主要问题是我没有完全阅读文档!虽然从11.1的网址变化已经足够了但我没有看到update_with_media的新网址, 正如documentation中所解释的那样,https://api.twitter.com/1.1/statuses/update_with_media.json api ,而不是旧的上传子域。

所以,现在我的api电话看起来像这样,一切都有效:

$code = $tmhOAuth->request('POST', 'https://api.twitter.com/1.1/statuses/update_with_media.json',
        array(
            'media[]'  => "@{$image}",
            'status'   => "{$text}"
        ),
        true, // use auth
        true  // multipart
    );

希望这有助于某人。

答案 1 :(得分:0)

使用abraham的twitteroauth api(更新到1.1版),而不是使用tmhOauth api:

https://github.com/abraham/twitteroauth/tree/master/twitteroauth

并按如下方式替换您的代码:

$connection = new TwitterOAuth($twitter_consumer_key, $twitter_consumer_secret, $twAccessToken, $twAccessTokenSecret);

$parameters = array(
            'media[]'  => "@{$image}",
            'status'   => "{$text}"
        );
$code = $connection->post('statuses/update_with_media', $parameters);     
相关问题