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: 21,241 Joined: 6th November 2002 From: Norwich, UK Member No.: 1 Device(s): HTC Touch HD |
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 -------------------- ![]() |
||
|
|
|||
|
Feb 19 2007, 10:48
Post
#2
|
||
![]() The Main Man Group: Admin Team Posts: 21,241 Joined: 6th November 2002 From: Norwich, UK Member No.: 1 Device(s): HTC Touch HD |
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: 21,241 Joined: 6th November 2002 From: Norwich, UK Member No.: 1 Device(s): HTC Touch HD |
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 | |
|---|---|---|---|---|---|
![]() |
Facebook on your mobile just got app'ed! | 29 | deadphill | 7,356 | Yesterday, 21:55 Last post by: jim.mason |
![]() |
Pinned: The easy way to boost your default volume settings |
130 | Hendrickson | 63,137 | Today, 01:36 Last post by: ciscokidinsf |
![]() |
A program to automate custom ROM creation tasks |
259 | sztupy | 12,218 | Yesterday, 23:03 Last post by: sector |
![]() |
New official update from Samsung site DXHK3 |
41 | bawdiest | 5,632 | Yesterday, 19:06 Last post by: memorrhagic |
![]() |
|
61 | Tran Trung | 5,989 | Yesterday, 20:53 Last post by: Arturro7 |
![]() |
Just Switched From Vario 3 Why did i bother ? Anyone help |
6 | kevr6384 | 72 | Yesterday, 13:25 Last post by: Kevlarski |
|
Lo-Fi Version | Time is now: 9th January 2009 - 05:09 |
Please visit our 'Plus Partners' - these companies support MoDaCo through 'MoDaCo Plus' - Click Here for more details!
ActiveKitten |
Aiko Solutions |
Ateksoft |
Binaryfish |
Conduits |
DeveloperOne |
eSoft Interactive |
FTouchSL |
Inesoft |
Lingvosoft |
monocube |
Mykesoft |
OmegaOne |
Omnisoft |
Opera Software |
Resco |
SBSH |
Slipstream Solutions |
SPB Software House |
Splashdata |
Sprite Software |
Syncdata |
Teksoft |
VITO |
WalkingHotSpot |
WebIS |
z4soft
Would your company like to become a 'Plus Partner'? Click Here to contact us!