I can confirm that it’s coming from Abraham’s twitterAuth library. I’ve switch part of my code to use https://github.com/themattharris/tmhOAuth and it looks like it’s working fine. This library must have an issue in the encoding of the file. I’ll report the bug on github.
Here is the new code I’m using:
$localFile = realpath($this->getTempLocalFile($url));
$params = array();
$params[‘media[]’] = ‘@’.$localFile;
if (null !== $message) {
$params[‘status’] = $message;
}
$tmhOAuth = new \tmhOAuth(array(
‘consumer_key’ => $this->consumerKey,
‘consumer_secret’ => $this->consumerSecret,
‘token’ => $this->oauthToken,
‘secret’ => $this->oauthTokenSecret,
));
$response = $tmhOAuth->user_request(array(
‘method’ => ‘POST’,
‘url’ => $tmhOAuth->url(“1.1/statuses/update_with_media”),
‘params’ => $params,
‘multipart’ => true
));