I m just looking forward to tweet something directly from a webpage without using the tweet box. Of course, after authentication. All i want is this. If the user is already logged in tweet directly if he clicks on the button. If not, provide an authentication screen and immediately after logging in tweet the text. And no use of tweet box. Any idea abt how this can be done? Thanks.
Is there any way to tweet something directly just with the click of a button without using tweetbox?
2 Answers
I have made a javascript function you can call onClick.. or just call the URL:
function tweet(url, text) {
url = encodeURIComponent(url);
text = encodeURIComponent(text);
window.open("http://twitter.com/intent/tweet?original_referer=" + url + "&text=" + text + "&url=" + url, "_blank");
}
I have used this on multiple project, easy to use, uses Twitter itself, simple and adds a short url to the message.
I am not 100% sure if this is what you are looking for, but can be handy.

- 12,501
- 3
- 44
- 72
-
Hi Marc Uberstein, may i please know what URL i ve to send to the tweet function. And text is the text that i need to tweet isn't it? – Sri Aug 12 '11 at 12:14
-
I have used the URL variable to link my own url. So in the tweet it will have the TEXT in the tweet, with a short url of your specified URL. You can play around and change it as you want it. Let me know if I have answered your question. – Marc Uberstein Aug 12 '11 at 12:30
-
Alright got it. But one of my important requirementS is that the tweet box should not appear at all! M looking for something like 'CLICK AND TWEET'. Y because, m trying to post the score of game. If the tweet box appears, the user can obviously change the score.!!! – Sri Aug 12 '11 at 12:39
-
I see... mmmmmm.. what you can do is generate a unique link to display the score. So in your tweet you can have e.g. "Hey friends, click the link and look at my score!" .. in this way users will never be able to supply false information. Just an idea from myside. ;) – Marc Uberstein Aug 12 '11 at 12:51
-
and if you really want to do posting without tweetbox. You have to setup a Twitter application, usint the API, oAuth etc. Ref : https://dev.twitter.com/docs – Marc Uberstein Aug 12 '11 at 12:53
Update
as @Curt commented below: Twitter is now only supporting oAuth so you might consider looking at the following answer related to oAuth Authorization with php: How can I use cURL (or any command line tool) to do an HTTP Post to Twitter, with OAuth authentication?
Yes!
Tweeter has an API you can do it through they are API or use something like this (using a server side script, PHP in this example):
Using the simple script below you, you can post updates to twitter. Please BE ADVISED: this script needs altered to run. As well as some extra code to add your desired functionality.
<?php
$username = 'myUserName';
$password = 'myPassword';
$status = urlencode(stripslashes(urldecode('This is a new Tweet!')));
if ($status) {
$tweetUrl = 'http://www.twitter.com/statuses/update.xml';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "$tweetUrl");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status");
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
$result = curl_exec($curl);
$resultArray = curl_getinfo($curl);
if ($resultArray['http_code'] == 200)
echo 'Tweet Posted';
else
echo 'Could not post Tweet to Twitter right now. Try again later.';
curl_close($curl);
}
?>
Good Luck!

- 1
- 1
-
1Correct me if I'm wrong, but I believe Twitter only allows access via oAuth now? – Curtis Aug 12 '11 at 11:29
-
@curt: Thanks for your comment correct, I have used this back in 2009 and after looking at the question I went straight to my bookmarks and posted a copy of that page here. I will update my answer. – Aug 12 '11 at 11:39
-
Hi Curt, Thanks for the response but I m trying to implement this just with the help of Javascripts. – Sri Aug 12 '11 at 12:26
-
In old times,maybe true, but now, you have to use an app to do this – Umut KIRGÖZ Apr 16 '14 at 09:13