Location: PHPKode > scripts > King James Bible PHP Script > bible-php-script/__LINUX/twitterAPI.php
 <?php
function postToTwitter($username,$password,$message){
 
    $host = "http://twitter.com/statuses/update.xml?status=".urlencode(stripslashes(urldecode($message)));
 
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $host);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    curl_setopt($ch, CURLOPT_POST, 1);
 
    $result = curl_exec($ch);
    // Look at the returned header
    $resultArray = curl_getinfo($ch);
 
    curl_close($ch);
 
    if($resultArray['http_code'] == "200"){
         $twitter_status='Your message has been sent! <a target="_blank" href="http://twitter.com/'.$username.'">See your message on Twitter</a>';
    } else {
         $twitter_status="Error posting to Twitter. Retry";
    }
	return $twitter_status;
}
?>
Return current item: King James Bible PHP Script