Available for a limited time only - £10 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 (MVP)
post Dec 14 2006, 19:50
Post #1


The Main Man
Group Icon

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 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


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


The Main Man
Group Icon

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


--------------------
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 (MVP)
post Feb 20 2007, 10:39
Post #4


The Main Man
Group Icon

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 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 Facebook on your mobile just got app'ed!
29 deadphill 7,356 Yesterday, 21:55
Last post by: jim.mason
No new Pinned: Topic has attachmentsHow to adjust your volume levels
The easy way to boost your default volume settings
130 Hendrickson 63,137 Today, 01:36
Last post by: ciscokidinsf
No new Topic has attachmentsSYAKR - SztupY's automated kitchen ROMbot [xip/sys updating beta tasks]
A program to automate custom ROM creation tasks
259 sztupy 12,218 Yesterday, 23:03
Last post by: sector
No new New official update from Samsung site
DXHK3
41 bawdiest 5,632 Yesterday, 19:06
Last post by: memorrhagic
No new Topic has attachmentsNew New DXHL2 M2D V11 from PDAVIET
61 Tran Trung 5,989 Yesterday, 20:53
Last post by: Arturro7
No New Posts Just Switched From Vario 3
Why did i bother ? Anyone help
6 kevr6384 72 Yesterday, 13:25
Last post by: Kevlarski

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 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!