Updating your Twitter status from PHP |
![]() ![]() |
Updating your Twitter status from PHP |
|
Dec 14 2006, 19:50
Post
#1
|
||
![]() The Main Man! 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
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 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 ![]() |
||
|
|
|||
|
Feb 19 2007, 10:48
Post
#2
|
||
![]() The Main Man! 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 |
||
|
|
|||
Feb 20 2007, 10:24
Post
#3
|
|||
|
Newbie 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 |
||
|
|
|||
|
Feb 20 2007, 10:39
Post
#4
|
||
![]() The Main Man! 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 P |
||
|
|
|||
Feb 20 2007, 12:15
Post
#5
|
|||
|
Newbie Group: Posters Posts: 2 Joined: 20th February 2007 Member No.: 231,485 |
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 P Ok, I submitted a request via contact page. I'll let you know if they respond. |
||
|
|
|||
|
Mar 4 2007, 09:01
Post
#6
|
||
![]() Newbie 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.
|
||
|
|
|||
![]() ![]() |
Similar Topics
| Topic | Replies | Topic Starter | Views | Last Action | |
|---|---|---|---|---|---|
![]() |
Post pics of your current UI, display wallpaper, background..anything |
630 | SwagR | 115,287 | Today, 18:17 Last post by: denteno |
![]() |
Post pics of your current UI, display wallpaper, background, etc |
525 | tacchan23 | 75,397 | Today, 17:50 Last post by: omar junior |
![]() |
crackling voice coming from your i8000 | 4 | asus535 | 607 | Today, 10:45 Last post by: mymimi |
![]() |
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 |
![]() |
This Opera 9.5 intended for lite rom user |
11 | NewForce | 529 | Yesterday, 23:26 Last post by: NewForce |
![]() |
Uninstall quicklinks from Home tab | 0 | deio | 9 | Today, 18:16 Last post by: deio |
|
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!