How can I tweet in twitter from my website? I am using a PHP script. Whatever tweets I send from my website should update my twitter account. I use the following code, but it is not updating in my twitter account:
// Set username and password
$username='myusername';
$password='*********';
// The message you want to send
$message = 'Nice to c all again.Have a nice day..';
// The twitter API address
$url='http://twitter.com/statuses/update.xml';
// Alternative JSON version
// $url = 'http://twitter.com/statuses/update.json';
// Set up and execute the curl process
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST,1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS,"status=".$message);
curl_setopt($curl_handle, CURLOPT_USERPWD,"$username:$password");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
// check for success or failure
if (empty($buffer)) {
echo 'Try again';
} else {
echo 'success';
}
This script is returning a success message, but when I check my twitter account no tweets are found.
What could be the problem?
Type your Tweet (up to 280 characters) into the compose box at the top of your Home timeline, or select the Tweet button in the navigation bar. You can include up to 4 photos, a GIF, or a video in your Tweet. Select the Tweet button to post the Tweet to your profile.
With this API, you can: Retweet other tweets. Retweet and edit tweets.
Essential. With Essential access, you can now get access to Twitter API v2 quickly and for free!
You are trying to send tweets using Basic Authentication (user name and password). This is no longer allowed. There are many examples of this online, but Twitter turned it off last August. You now have to use OAuth to do authentication.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With