Available for a limited time only - £5 off a £20 spend at eXpansys! For more details visit this topic!

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: 21,816
Favorited Topics: 51
Joined: 6th November 2002
From: Norwich, UK
Member No.: 1

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



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


--------------------
My current devices of choice - HTC Touch HD (Miri 6.5 v11), White T-Mobile G1 (Haykuro ADP1.5Hr3-A2SD), Samsung Blackjack II (6.1 stock)

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: 21,816
Favorited Topics: 51
Joined: 6th November 2002
From: Norwich, UK
Member No.: 1

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



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: 21,816
Favorited Topics: 51
Joined: 6th November 2002
From: Norwich, UK
Member No.: 1

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



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
Tags
No Tag inserted yet


Collapse

Similar Topics

  Topic Replies Topic Starter Views Last Action
No new Omnia upgrade from Portugal
26 LAMEIRAS 1,525 Yesterday, 00:39
Last post by: lourenco
No new Pinned: Topic has attachmentsHow to Flash your i900 Omnia phone
Flashing tutorial for newbies and not only!
28 sector 10,808 Today, 05:08
Last post by: nxtvctm
No New Posts Help updating from ACHJ2 to DXIA5
2 rossyl 94 Yesterday, 17:47
Last post by: emmdeb
No New Posts how to remove a program from automatically starting up during a reboot?
1 jbrittmartin 68 Yesterday, 03:53
Last post by: natedawg1013
No New Posts cannot delete files from library of touchplayer
anyone got the same problem? got a solution?
0 kav 22 Yesterday, 08:35
Last post by: kav
No New Posts This week's Friday Deals from eXpansys - Benq E72 for £49.99
0 Paul 236 Yesterday, 10:03
Last post by: Paul

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

 


RSS hit counter Lo-Fi Version Time is now: 4th July 2009 - 10:08

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!