Created
July 19, 2012 09:25
-
-
Save lamprosg/3142647 to your computer and use it in GitHub Desktop.
Simple post message to twitter with PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $url = 'http://twitter.com/statuses/update.xml'; | |
| $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); | |
| if (empty($buffer)) { | |
| echo "Error. Please check your username/password!"; | |
| } else { | |
| echo "Posted"; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment