简体   繁体   English

亚伯拉罕的twitteroauth库可用于update_with_media吗?

[英]does abraham's twitteroauth library work for update_with_media?

does abraham's twitteroauth library work for update_with_media? 亚伯拉罕的twitteroauth库可用于update_with_media吗?

I'm using below code but it returns me stdClass Object ( [request] => /1/statuses/update_with_media.json [error] => Error creating status. ) 我正在使用下面的代码,但它返回我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');

Any one any idea how to solve this problem? 有谁知道如何解决这个问题?

EDIT 1: I am using https://upload.twitter.com/1/ as url 编辑1:我使用https://upload.twitter.com/1/作为网址

Yes it does! 是的,它确实! Change the two files Oauth.php and twitteroauth.php as the described at this link https://github.com/robhaswell/twitteroauth/commit/7f5bfd2450cb1cff71641d7ea55e118f5a42885d and use $connection->upload method like this. 按照此链接中的描述更改两个文件Oauth.php和twitteroauth.php https://github.com/robhaswell/twitteroauth/commit/7f5bfd2450cb1cff71641d7ea55e118f5a42885d并使用$ connection-> upload方法。

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

As per library author answer elsewhere - No it does not work with update_with_media yet. 按照库作者的其他答案-不,它不适用于update_with_media。

TwitterOAuth does not currently support media uploads. TwitterOAuth当前不支持媒体上传。 I hope to add support in the future. 我希望将来增加支持。 on 10th of May by @abraham at update_with_media using abraham's twitteroauth @abraham于5月10日使用abraham的twitteroauth在update_with_media上

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

A little change if update_with_media is not working 如果update_with_media不起作用,请稍作更改

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM