gpt4 book ai didi

php - 推特 API 1.1 update_with_media

转载 作者:可可西里 更新时间:2023-11-01 00:14:45 28 4
gpt4 key购买 nike

我正在更改我的 PHP 代码以与新的 API 兼容,但我一直在使用 update_with_media。这是我的代码:

$image = constant('PATH_UPLOAD').$db_data['post_image'];
$connection = new TwitterOAuth(constant('CONSUMER_KEY'), constant('CONSUMER_SECRET'), $db_data['tw_oauth_token'], $db_data['tw_oauth_secret']);
$content = $connection->OAuthRequest('https://api.twitter.com/1.1/account/verify_credentials.json', 'GET', array());
$twitterInfo = json_decode($content);
$resp_tw = $connection->OAuthRequest('https://api.twitter.com/1.1/statuses/update_with_media.json', 'POST',
array(
'status' => html_entity_decode($db_data['post_text'],ENT_QUOTES,'UTF-8'),
'media[]' => "@{$image}"
)
);

它返回

{"errors":[{"code":189,"message":"Error creating status"}]}

可能是什么问题/我做错了什么?

最佳答案

你可以这样尝试:

$tmhOAuth = new tmhOAuth(array(
'consumer_key' => 'abc',
'consumer_secret' => 'abc',
'user_token' => 'abc',
'user_secret' => 'abc',
));

$response = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update_with_media'),
array(
'status' => $message,
'media[]' => file_get_contents($image)
));
if ($response != 200) {
//Do something if the request was unsuccessful
}

有我的代码测试https://twitter.com/wallapps/status/357137553691906048

关于php - 推特 API 1.1 update_with_media,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17081992/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com