Take a look at Abraham Williams' excellent Twitter PHP Oauth lib: http://twitter.abrah.am/
-Chad On Tue, Apr 21, 2009 at 4:36 PM, Doug D <[email protected]> wrote: > > I've been digging in to the Twitter OAuth stuff and am able to sign > into my site with the Twitter authentication, but I'm wondering if > there is a way to use the OAuth credentails to send a status update > using PHP and cURL. The code below sends an update, but only when a > static username:password is filled in. > > My goal it to update (your) Twitter status from my site once you are > authenticated by Twitter. Any thoughts or tutorials? Thanks! > > // Set username and password > $username = 'name'; > $password = 'password'; > > // The message you want to send > $message = 'My status update'; > > // The twitter API address > $url = 'http://twitter.com/statuses/update.xml'; > > // Alternative JSON version > // $url = 'http://twitter.com/statuses/update.json'; > > // Set up and execute the curl process > $curl_handle = curl_init(); > > curl_setopt($curl_handle, CURLOPT_URL, "$url"); > curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); > curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); > curl_setopt($curl_handle, CURLOPT_POST, 1); > curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message"); > curl_setopt($curl_handle, CURLOPT_USERPWD, "$username:$password"); > $buffer = curl_exec($curl_handle); > curl_close($curl_handle); > > > // check for success or failure > if (empty($buffer)) { > echo 'message'; > } else { > echo 'success'; > } >
