How can i post image along with text on timeline using PHP


#1

I want to post image and text on my timeline.Here is my code :-

 $twitteroauth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['TWITTER_token'], $_SESSION['TWITTER_token_secret']);
		$user_info = $twitteroauth->get('account/verify_credentials');
		$message = $_POST['message']; // I have added a message here
		$image = $_FILES ['file']  ['tmp_name'];
		$statuesIMAGE= $twitteroauth->post('statuses/update_with_media', array('media[]' => '@{$image}','status' => $message));

please reply/If some have sample(running code) please give me.Thanks


#2

There is a full example under media.


#3

i am using code (from your reference):–

$twitteroauth = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['TWITTER_token'], $_SESSION['TWITTER_token_secret']);
$media1 = $twitteroauth->upload('media/upload', array('media' => '../images/android.png'));
print_r($media1);
 $media2 = $twitteroauth->upload('media/upload', array('media' => '../images/ios.png'));
$parameters = array(
    'status' => 'Images',
    'media_ids' => implode(',', array($media1->media_id_string, $media2->media_id_string)),
);
$result = $twitteroauth->post('statuses/update', $parameters);
print_r( $result);

But it shows nothing.


#4

hello sir please help me. i struct in this from 4 days back…Please reply ASAP


#5

What do you mean it shows nothing? there should at least be some error of some sort.


#6

it return blank screen.


#7

That’s a PHP error, you need to turn on errors or look at the log and see why.