2

does abraham's twitteroauth library work for 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. )

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

5

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.

 $params = array('media[]' => '@'.$image_url, 'status' => $messafe);
 $twit = $connection->upload('statuses/update_with_media',$params);
  • Thank you! This answer should be marked as correct! – Nikola May 19 '13 at 13:47
  • 2
    Since api 1.1, you have to change proposed "upload" method in twitterOAuth.php. Juste delete the 2 definitions of $this->host (line 168 and 170 on github diff). Worked for me, thank you! – Atyz Jul 11 '13 at 14:06
0
 $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

2

As per library author answer elsewhere - No it does not work with update_with_media yet.

TwitterOAuth does not currently support media uploads. I hope to add support in the future. on 10th of May by @abraham at update_with_media using abraham's twitteroauth

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.