Hi,
I am trying to develop a web page which would allow a user to log in and send a tweet to their account, from that webpage.
This is the code I have so far -
<?php
// Include twitteroauth
require('twitteroauth.php');
// Set keys
$consumerKey = 'XXXXXXXXXXXXXXXXXX';
$consumerSecret = 'XXXXXXXXXXXXXXXXXXXX';
$accessToken = 'XXXXXXXXXXXXXXXXXXXX';
$accessTokenSecret = 'XXXXXXXXXXXXXXXXXXXXX';
// Create object
$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
// Set status message
$tweetMessage = 'Twitter :D';
// Check for 140 characters
if(strlen($tweetMessage) <= 140)
{
// Post the status message
$tweet->post('statuses/update', array('status' => $tweetMessage));
echo "Tweet Posted";
}
?>
This code is hard coded to send tweets through my account. My question is, how can I modify this to authenticate a user and post tweets to his account? (I’m guessing I shouldn’t hard code all the 4 keys, but I’m not sure).
Any guidance here is largely appreciated!
Thanks,
Sainath