Skip to content

Instantly share code, notes, and snippets.

@vjnrv
Created April 22, 2010 02:56
Show Gist options
  • Save vjnrv/374749 to your computer and use it in GitHub Desktop.
Save vjnrv/374749 to your computer and use it in GitHub Desktop.
<?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