]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - wordpress-plugin/ozh-plc-bridge/inc/twitter.php
Initial commit (importing from http://svn.planetozh.com/ozhin)
[Github/YOURLS.git] / wordpress-plugin / ozh-plc-bridge / inc / twitter.php
1 <?php
2
3 // Send a message to Twitter. Returns boolean for success or failure.
4 function wp_ozh_yourls_tweet_it($username, $password, $message){
5
6     $host = "http://twitter.com/statuses/update.xml?status=".urlencode(stripslashes(urldecode($message)));
7
8     $ch = curl_init();
9     curl_setopt($ch, CURLOPT_URL, $host);
10     curl_setopt($ch, CURLOPT_VERBOSE, 1);
11     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
12     curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
13     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
14     curl_setopt($ch, CURLOPT_POST, 1);
15
16     // Go for it!!!
17     $result = curl_exec($ch);
18     // Look at the returned header
19     $resultArray = curl_getinfo($ch);
20
21     // close curl
22     curl_close($ch);
23
24     //echo "http code: ".$resultArray['http_code']."<br />";
25         return ($resultArray['http_code'] == "200");
26
27 }
28
29 // Debug function
30 function wp_ozh_yourls_tweet_log($username, $password, $message) {
31         $f = fopen('/DONNEES/I07143/MES_DOCUMENTS/utils/xampp/xampp/htdocs/wordpress/wp-content/plugins/ozh-plc-bridge/tweet.log', 'a');
32         fputs($f, "$username: $message\n");
33         fclose($f);
34 }