php - abraham 的 twitteroauth 库是否适用于 update_with_media?

标签 php twitter twitter-oauth

abraham 的 twitteroauth 库是否适用于 update_with_media?

我正在使用下面的代码,但它返回了我的 stdClass 对象 ( [请求] =>/1/statuses/update_with_media.json [错误] => 创建状态时出错。 )

session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');


if (empty($_SESSION['access_token']) || empty($_SESSION['access_token']['oauth_token']) || empty($_SESSION['access_token']['oauth_token_secret'])) {
  header('Location: ./clearsessions.php');
}

 $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET,$_SESSION['access_token']['oauth_token'], $_SESSION['access_token']['oauth_token_secret']);

$image = './images/5298.png';
$content = $connection->post('statuses/update_with_media', 
  array(
   'media[]' => '@{$image};type=image/jpeg;filename={$image}', 
   'status' => 'My current location'));

include('html.inc');

有人知道如何解决这个问题吗?

编辑 1: 我正在使用 https://upload.twitter.com/1/作为网址

最佳答案

是的!按照此链接 https://github.com/robhaswell/twitteroauth/commit/7f5bfd2450cb1cff71641d7ea55e118f5a42885d 中的描述更改两个文件 Oauth.php 和 twitteroauth.php并像这样使用 $connection->upload 方法。

 $params = array('media[]' => '@'.$image_url, 'status' => $messafe);
 $twit = $connection->upload('statuses/update_with_media',$params);

关于php - abraham 的 twitteroauth 库是否适用于 update_with_media?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11243612/

相关文章:

python - Ubuntu Box 偶尔使用 Twitter API 浪费时间

php - jQuery/PHP 喜欢/不喜欢按钮

javascript - 在 Sweet Alert 中加载 html?

php - 通过 odbc 在 filemaker 中选择日期

objective-c - 自定义 iOS Twitter 身份验证页面?

iframe - 是否可以让 oAuth 留在 iFrame 中而不占用父窗口?

php - 根据日期在不同的表中显示数据

c# - 未将对象引用设置为实例

java - Twitter4J sendDirectMessage 返回页面不存在

iphone - 如何使用 iOS 的 api 1.1 获取 Twitter 个人资料图片?