public
Description: Implementations in different languages to post to Twitter your IP (for use with a home server?)
Homepage: http://bluescripts.net/
Clone URL: git://github.com/bluescripts/iptweet.git
iptweet / php / iptweet.php
100755 28 lines (22 sloc) 1.027 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env php
<?php
$f = file("http://bb.bluescripts.net/ip.php");
$ip = $f[0];
 
                       $post_data['status'] = $ip;
                       $url = "http://twitter.com/statuses/update.xml";
                       $o="";
                       foreach ($post_data as $k=>$v)
                       {
                           $o.= "$k=".utf8_encode($v)."&";
                       }
                       $post_data=substr($o,0,-1);
                      
                       $ch = curl_init();
                       curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                       curl_setopt($ch, CURLOPT_USERPWD, 'USERNAME:PASSWORD');
                       curl_setopt($ch, CURLOPT_POST, 1);
                       curl_setopt($ch, CURLOPT_HEADER, 0);
                       curl_setopt($ch, CURLOPT_URL, $url);
                       curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
                       $result = curl_exec($ch);
//echo $result;
 
 
 
?>