JSHINER Posted August 12, 2008 Share Posted August 12, 2008 I'm messing around with the Twitter API and need to get started with cURL How would I pass this onto Twitter using PHP? curl -u email:password -d status="your message here" http://twitter.com/statuses/update.xml Thanks! Link to comment https://forums.phpfreaks.com/topic/119298-using-php-and-curl-getting-started/ Share on other sites More sharing options...
JSHINER Posted August 12, 2008 Author Share Posted August 12, 2008 Found this: <?php // Set username and password $username = 'username'; $password = 'password'; // The message you want to send $message = 'is twittering from php using curl'; // 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'; } ?> Link to comment https://forums.phpfreaks.com/topic/119298-using-php-and-curl-getting-started/#findComment-614524 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.