Revision: 37811
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 17, 2010 15:51 by kijtra
Initial Code
function t_co($url){ $user='[Your Twitter Account Name]'; $pass='[Your Twitter login Password]'; $params=array( 'url'=>$url, 'session[username_or_email]'=>$user, 'session[password]'=>$pass, 'commit'=>'LOGIN' ); $ch=curl_init('http://twitter.com/share'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch,CURLOPT_POST,TRUE); curl_setopt($ch,CURLOPT_POSTFIELDS,$params); curl_setopt($ch,CURLOPT_HTTPHEADER,array('Expect:')); $output=curl_exec($ch); curl_close($ch); preg_match('/<textarea[^>]+>([^<]+)<\/textarea>/',$output,$match[1]); if(!empty($match[1][1])){ return trim($match[1][1]); } } # Example echo t_co('http://google.co.jp/');
Initial URL
Initial Description
Initial Title
Shorten URL to Twitter \"t.co\"
Initial Tags
Initial Language
PHP