Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
tmhOauth twitter api停止使用update_with_media调用_Twitter - Fatal编程技术网

tmhOauth twitter api停止使用update_with_media调用

tmhOauth twitter api停止使用update_with_media调用,twitter,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}]} 由于我使用了,我去看看是否有更新,似乎有一个问题列出 我正在使用api更新媒体的状态,如下所示: $code = $tmhOA

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

{"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}]}
由于我使用了,我去看看是否有更新,似乎有一个问题列出

我正在使用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
,但它仍然不起作用。

我的主要问题是我没有完全阅读文档!虽然url从
1
更改为
1.1
已经足够了,但我没有注意到更新媒体的新url, 如中所述,is
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
    );

希望这对其他人有所帮助。

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

并按如下方式替换代码:

$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);     

$image imageurl是吗?@Tahtakafa:是的。