Skip to content

Instantly share code, notes, and snippets.

@mgng
Created February 19, 2013 05:24
Show Gist options
  • Save mgng/4983316 to your computer and use it in GitHub Desktop.
Save mgng/4983316 to your computer and use it in GitHub Desktop.
<?php
require_once '/path/to/tmhOAuth/tmhOAuth.php';
$obj = new tmhOAuth( array(
'consumer_key' => 'consumer_key',
'consumer_secret' => 'consumer_secret',
'user_token' => 'access_token',
'user_secret' => 'access_token_secret',
) );
$file = 'test.jpg';
$image = file_get_contents( $file );
$imagesize = getimagesize( $file );
$api_url = 'https://api.twitter.com/1.1/statuses/update_with_media.json';
$params = array(
'status' => "hey",
'media[]' => $image . ";type=" . $imagesize['mime'] . ";filename=" . basename( $file ),
);
$code = $obj->request( 'POST', $api_url, $params );
$response = $obj->response['response'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment