D
D
Deterrent2016-08-04 21:17:42
PHP
Deterrent, 2016-08-04 21:17:42

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' => 'проверка'));

I can through twitteroauth;
like this
$connection->post('statuses/update', array('status' => "Доброе утро!"));

But nothing is given statuses/update_with_media
to me, no matter how I fight, no matter what I do.
require_once('twitteroauth.php');
.....
$image = file_get_contents('beer.jpg');
$connection->post('statuses/update_with_media', array('media[]' => $image));

doesn't want
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}"));

also no
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}"));

and so no .....
Duck as then :( killed already

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-08-05
@user004

Googled the answer to the first link.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question