Thanks Alex. After looking into this further, I eventually found the
following PHP/curl snippet that seems to plug into the status update
API very well and do what I was trying to do. I tested it and it
works, even authenticates, but lacks the actual html text area where
the user (really just me) would enter the text to post from a web
page. (Instead it just has a default message on the $message = line
below so always posts the same message to Twitter) I think it's a
simple matter of placement of the html snippet for a text area. Would
you agree? If so, where in your opinion would I insert a vanilla text
area in or around this code below? Thanks for your patience with me on
this.
?php
// Set username and password
$username = 'username';
$password = 'password';
// The message you want to send
$message = 'is twittering from php using curl';
// 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 'message';
} else {
echo 'success';
}
?
On Nov 6, 1:47 am, Alex Payne [EMAIL PROTECTED] wrote:
There's not a particularly easy way to do that using just client-side
HTML and JavaScript, no.
On Wed, Nov 5, 2008 at 9:00 PM, fumbler [EMAIL PROTECTED] wrote:
Thanks. That pre-populates the Twitter status box after asking the
user to log in. What I'm trying to do is to post directly to Twitter,
and skip the login screen by passing the user/pass along with the post
if possible, since it will always be the same user anyway the user
pass can be hardcoded into the snippet. Is there an easy way to do
that? Either way, look forward to your new drop-in widget but hope to
continue exploring this route in the meantime. Thanks!
On Nov 4, 4:08 pm, Alex Payne [EMAIL PROTECTED] wrote:
The way a number of sites do this is to provide an input box that then
posts to our logged-in user home page with the status parameter
filled out with what the user typed on the referring site. This HTML
would do the trick:
form action=http://twitter.com/home; method=get
textarea name=statustweet goes here/textarea
input type=submit value=update /
/form
Good luck!
On Tue, Nov 4, 2008 at 9:54 AM, drupalot [EMAIL PROTECTED] wrote:
Thanks, I really look forward to that.
Meanwhile as a placeholder I have an interim super-simple box that
looks like it's almost working. Could you glance at this snippet and
perhaps let me know what I'm missing if it's something obvious?
FORM ACTION=http://twitter.com/statuses/update.format;
METHOD=POSTYour tweet:BR TEXTAREA NAME=tweet COLS=40 ROWS=6/
TEXTAREA PINPUT TYPE=SUBMIT VALUE=submit /FORM
I would like to pass username and password as well if there's a quick
line of simple html for that?
Thanks, and once again please forgive me my newbie-ness on this.
On Nov 3, 7:55 pm, Alex Payne [EMAIL PROTECTED] wrote:
If you can hold on for a week or so, we're about to release a nifty
new version of our drop-in widgets. The widget allows users to update
and much more.
On Mon, Nov 3, 2008 at 12:01 PM, drupalot [EMAIL PROTECTED] wrote:
In your opinion, what is the easiest way to add the What are you
doing? update box to a site? For starters, it's okay for me if the
update box is tuned to just one account.
Admittedly, I'm pretty much a non-developer that is decent with Drupal
and just starting to learn php, but am working on a project with a
friend that would require adding the Twitter update box to just one
page. If there is a way to embed the box as a widget through html or
php into a page, that would be ideal. Or if there are step-by-step
instructions for the full API I might be able to swing it, but not
sure I can tell from the API how that's done at this point. So far,
what I've found in the API is the following, and I'm embarrassed to
say I'm not sure how to do it with just these instructions:
Post a status update, authenticated: curl -u email:password -d
status=your message herehttp://twitter.com/statuses/update.xml
Any thoughts for a newbie?
--
Alex Payne - API Lead, Twitter, Inc.http://twitter.com/al3x
--
Alex Payne - API Lead, Twitter, Inc.http://twitter.com/al3x
--
Alex Payne - API Lead, Twitter, Inc.http://twitter.com/al3x