Please Log In or Register - it's FREE!

 
Reply to this topicStart new topic
 Updating your Twitter status from PHP
Paul
post Dec 14 2006, 19:50
Post #1


The Main Man!
Group Icon

Group: Admin Team
Posts: 24,398
Favorited Topics: 76
Joined: 6th November 2002
From: Norwich, UK
Member No.: 1

Device(s): Touch HD / G1
Twitter: @paulobrien



For one of the interesting projects i've been working on, i've needed to update my Twitter status from within a PHP script... and I thought the code to do it (that uses the Twitter API) might be of interest to others... so here it is smile.gif

CODE
<?php

$email = $_GET['email'];
$password = $_GET['password'];
$status = urlencode( $_GET['status'] );

$url = "http://8.7.217.31/statuses/update.xml";

$session = curl_init();
curl_setopt ( $session, CURLOPT_URL, $url );
curl_setopt ( $session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt ( $session, CURLOPT_HEADER, false );
curl_setopt ( $session, CURLOPT_USERPWD, $email . ":" . $password );
curl_setopt ( $session, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $session, CURLOPT_POST, 1);
curl_setopt ( $session, CURLOPT_POSTFIELDS,"status=" . $status);
$result = curl_exec ( $session );
curl_close( $session );

echo( $result );

?>

Simple but effective wink.gif

P


--------------------
Follow me on Twitter - http://twitter.com/paulobrien / Follow MoDaCo on Twitter - http://twitter.com/modaco

For Sale (Norfolk, UK) - 2007 (07) Mazda 6 MPS, 2.3 Turbo 4WD 256bhp / Black Mica / 20GB Bose / DVD Nav / K&N + much more, 47k miles - £9,995 - PM me for details

Go to the top of the page
 
+Quote Post
Paul
post Feb 19 2007, 10:48
Post #2


The Main Man!
Group Icon

Group: Admin Team
Posts: 24,398
Favorited Topics: 76
Joined: 6th November 2002
From: Norwich, UK
Member No.: 1

Device(s): Touch HD / G1
Twitter: @paulobrien



Updated to do status post rather than get.

Naughty me!

P
Go to the top of the page
 
+Quote Post
Jaakko
post Feb 20 2007, 10:24
Post #3


Newbie
Group Icon

Group: Posters
Posts: 2
Joined: 20th February 2007
Member No.: 231,485



Hi,

I have also played with similar php twitter uploader script but I encountered a problem when using scandinavian characters like ä or ö.

I've encoded the status message characters with the url encoder like this:

$status = urlencode ($status);

However, it doesn't work. The status text which appears in the twitter site is cut from the first scandinavian character. Has someone any proposals how to make this work or is this a bug on twitter side?

Jaakko
Go to the top of the page
 
+Quote Post
Paul
post Feb 20 2007, 10:39
Post #4


The Main Man!
Group Icon

Group: Admin Team
Posts: 24,398
Favorited Topics: 76
Joined: 6th November 2002
From: Norwich, UK
Member No.: 1

Device(s): Touch HD / G1
Twitter: @paulobrien



Assuming the $status variable is intact when you go into that line (worth checking), then the urlencode should fix it AFAIK, so perhaps it is something odd Twitter are doing.

I'd suggest dropping them a mail, they're generally pretty good at replying smile.gif

P
Go to the top of the page
 
+Quote Post
Jaakko
post Feb 20 2007, 12:15
Post #5


Newbie
Group Icon

Group: Posters
Posts: 2
Joined: 20th February 2007
Member No.: 231,485



QUOTE(Paul (MVP) @ Feb 20 2007, 12:39) *
Assuming the $status variable is intact when you go into that line (worth checking), then the urlencode should fix it AFAIK, so perhaps it is something odd Twitter are doing.

I'd suggest dropping them a mail, they're generally pretty good at replying smile.gif

P


Ok, I submitted a request via contact page. I'll let you know if they respond.
Go to the top of the page
 
+Quote Post
dropkernel
post Mar 4 2007, 09:01
Post #6


Newbie
Group Icon

Group: Posters
Posts: 1
Joined: 4th March 2007
Member No.: 235,088



Try wrapping the message using utf8_encode() function. This works for me when posting an update using PHP and curl.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

Similar Topics

  Topic Replies Topic Starter Views Last Action
No new Topic has attachmentsSHOW US YOUR DISPLAY!!
Post pics of your current UI, display wallpaper, background..anything
630 SwagR 115,287 Today, 18:17
Last post by: denteno
No new Topic has attachmentsSHOW YOUR DISPLAY!
Post pics of your current UI, display wallpaper, background, etc
525 tacchan23 75,397 Today, 17:50
Last post by: omar junior
No New Posts crackling voice coming from your i8000
4 asus535 607 Today, 10:45
Last post by: mymimi
No New Posts SportyPal - Track your workout through GPS
sportypal sports tracker omnia pro B7610 winmo 6.1 and 6.5
2 ednakram 178 Today, 13:58
Last post by: liksur
No New Posts Topic has attachmentsOpera Mobile 9.5 build 18250 (packed from secany JA5)
This Opera 9.5 intended for lite rom user
11 NewForce 529 Yesterday, 23:26
Last post by: NewForce
No New Posts Uninstall quicklinks from Home tab
0 deio 9 Today, 18:16
Last post by: deio

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 


RSS hit counter Lo-Fi Version Time is now: 9th February 2010 - 19:11

Please visit our 'Plus Partners' - these companies support MoDaCo through 'MoDaCo Plus' - Click Here for more details!

ActiveKitten | Binaryfish | Conduits | DeveloperOne | eSoft Interactive | FTouchSL | Inesoft | LastPass

Lingvosoft | monocube | OmegaOne | Omnisoft | Opera Software | Resco | SBSH | Splashdata

Sprite Software | Syncdata | Teksoft | Titanium Backup | VITO | WalkingHotSpot | WebIS | z4soft

Would your company like to become a 'Plus Partner'? Click Here to contact us!