We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is a COPY of Issue 314: Shortener in sharetronix, filed on Google Code before the project was moved on Github.
Please review the original issue and especially its comments. Comments here on closed issues will be ignored. Thanks.
The default shortener in sharetronix is bit.ly I want to use my own shortener ofcourse! I came up to this code (i'm not a great programmer) but the shortened url is not copied to twitters status. Can anybody point me in the correct direction :-) $bitly = 'http://urli.nl/api.php?&format=json&action=shorturl&url='.$url; $result = @file_get_contents($bitly); if( !$result || empty($result) ) { $this->redirect('http://twitter.com/home? status='.urlencode($status)); exit; } $result = @json_decode($result, TRUE); if( !$result || !isset($result['statusCode']) || $result['statusCode']!=200 || !isset($result['results']) ) { $this->redirect('http://twitter.com/home? status='.urlencode($status)); exit; } $result = reset($result['results']); if( !$result || !isset($result['shorturl']) || empty($result['shorturl']) ) { $this->redirect('http://twitter.com/home? status='.urlencode($status)); exit; } $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; The original code: $bitly = 'http://api.bit.ly/shorten? version=2.0.1&longUrl='.$url.'&login='.$C->BITLY_LOGIN.'&apiKey='.$C- >BITLY_API_KEY; $result = @file_get_contents($bitly); if( !$result || empty($result) ) { $this->redirect('http://twitter.com/home? status='.urlencode($status)); exit; } $result = @json_decode($result, TRUE); if( !$result || !isset($result['statusCode']) || $result['statusCode']!='OK' || !isset($result['results']) ) { $this->redirect('http://twitter.com/home? status='.urlencode($status)); exit; } $result = reset($result['results']); if( !$result || !isset($result['shortUrl']) || empty($result['shortUrl']) ) { $this->redirect('http://twitter.com/home? status='.urlencode($status)); exit; } $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;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This is a COPY of Issue 314: Shortener in sharetronix, filed on Google Code before the project was moved on Github.
Please review the original issue and especially its comments. Comments here on closed issues will be ignored. Thanks.
Original description
The text was updated successfully, but these errors were encountered: