Answer the question
In order to leave comments, you need to log in
How to post a picture to twitter via API?
I can post text using tmhOAuth
like this
$response = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update'), array('status' => 'проверка'));
twitteroauth;
$connection->post('statuses/update', array('status' => "Доброе утро!"));
statuses/update_with_media
require_once('twitteroauth.php');
.....
$image = file_get_contents('beer.jpg');
$connection->post('statuses/update_with_media', array('media[]' => $image));
require_once('twitteroauth.php');
.....
$image_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'beer.jpg';
$binary = fopen($filename, "rb");
$image = fread($binary, filesize($filename));
fclose($binary);
$connection->post('statuses/update_with_media', array('media[]' => "{$image};type=image/jpeg;filename={$filename}"));
require 'tmhOAuth.php';
...
$filename = "beer.jpg";
$binary = fopen($filename, "rb");
$image = fread($binary, filesize($filename));
fclose($binary);
$code = $tmhOAuth->request('POST', $tmhOAuth->url('1.1/statuses/update_with_media'), array('media[]' => "{$image};type=image/jpeg;filename={$filename}"));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question