Answer the question
In order to leave comments, you need to log in
How to tweet with images in php using OAuth?
There is this code:
require_once "twitter/twitteroauth.php";
$CONSUMER_KEY = "нанана";
$CONSUMER_SECRET = "нанана";
$OAUTH_TOKEN = "нанана";
$OAUTH_SECRET = "нанана";
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $OAUTH_TOKEN, $OAUTH_SECRET);
$content = $connection->get('account/verify_credentials');
$quote='123';
$image='http://www.niceseo.ru/wp-content/uploads/2013/07/niceseotwitterapi11tweetwithphotodemoscript.jpg';
$connection->post('statuses/update ', array('status' => $quote));
print 'Размещена запись: "'.$quote.'"';
$name = basename($image);
$connection->user_request(array('method' => 'POST','url' => $connection->url('1.1/statuses/update_with_media'),'params' => array('media[]' => "@{$image};type=image/jpeg;filename={$name}",'status' => $quote,),'multipart' => true,));
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $network_array['consumer_key'],
'consumer_secret' => $network_array['consumer_secret'],
'user_token' => $network_array['user_token'],
'user_secret' => $network_array['user_secret']
));
$params = array(
'media[]' => '@' . $process_image['image_path'], //PATH TO IMAGE
'status' => $tweet_response, //THIS IS THE TEXT WE USE FOR THE TWEET
'in_reply_to_status_id' => $mentions[$c]["id"] //IF REPLYING, IT'S HERE
);
$code = $tmhOAuth->user_request(array(
'method' => 'POST',
'url' => $tmhOAuth->url("1.1/statuses/update_with_media"),
'params' => $params,
'multipart' => true
));
$name = basename($image);
$code = $connection->request(
'POST',
$connection->url('1.1/statuses/update_with_media'),
array(
'media[]' => "@{$image};type=image/jpeg;filename={$name}",
'status' => 'Picture time',
),
true,
true
);
$connection->post('statuses/update_with_media', array('media[]' => "@{$image};type=image/jpeg;filename={$name}",'status' => $quote));
$connection->post('statuses/update_with_media', array('media[]' => "@{$image};type=image/jpeg;filename={$name}",'status' => $quote),,'multipart' => true);
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