php - short array of links using bit.ly api -
i have found bit.ly api short links in php, need make loop, shortened array of links...
so, example, have array:
array ( [0] => http://longlink.com/1.php [1] => http://longlink.com/2.php [2] => http://longlink.com/3.php [3] => http://longlink.com/4.php [4] => http://longlink.com/5.php )
and need short new array this:
array ( [0] => http://bit.ly/... [1] => http://bit.ly/... [2] => http://bit.ly/... [3] => http://bit.ly/... [4] => http://bit.ly/... )
i have included bitty api (here) , usnig php code, can short 1 link
$bitly = new bitly('username', 'apikey'); echo $bitly->shorten('http://longlink.com/1.php');
but can tell me, how short array? thanks!
<?php $urls = array ( 'http://longlink.com/1.php', 'http://longlink.com/2.php', 'http://longlink.com/3.php', 'http://longlink.com/4.php', 'http://longlink.com/5.php', ); $result = array(); $bitly = new bitly('username', 'apikey'); foreach ($urls $url) { $result[] = $bitly->shorten($url); } print_r($result);
Comments
Post a Comment