Created
April 22, 2010 02:56
-
-
Save vjnrv/374749 to your computer and use it in GitHub Desktop.
This file contains 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/vjnrv'; | |
//$status = 'Testando urli.nl'; | |
$bitly = 'http://urli.nl/api.php?&format=json&action=shorturl&url='.$url; | |
$result = @file_get_contents($bitly); | |
if($result) | |
{ | |
$result = @json_decode($result, TRUE); | |
if($result['shorturl']) | |
{ | |
$result = $result['shorturl']; | |
$result = ': '.$result; | |
$reslen = mb_strlen($result); | |
$pmxlen = 140 - $reslen; | |
if(mb_strlen($status) > $pmxlen) | |
{ | |
$status = str_cut($status, $pmxlen-2); | |
} | |
$status .= $result; | |
$this->redirect('http://twitter.com/home?status='.urlencode($status)); | |
exit; | |
//echo $status; | |
} | |
else | |
{ | |
$this->redirect('http://twitter.com/home?status='.urlencode($status)); | |
exit; | |
} | |
} | |
else | |
{ | |
$this->redirect('http://twitter.com/home?status='.urlencode($status)); | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment