我在 php 中找到了用于短链接的 bit.ly api,但我需要创建一个循环,其中将缩短一系列链接......
因此,例如,我有数组:
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
)
我需要将它缩短为这样的新数组:
Array
(
[0] => http://bit.ly/...
[1] => http://bit.ly/...
[2] => http://bit.ly/...
[3] => http://bit.ly/...
[4] => http://bit.ly/...
)
我已经包含了 bitty api ( HERE ) 和 usnig php 代码,我可以缩短一个链接
$bitly = new bitly('username', 'apikey');
echo $bitly->shorten('http://longlink.com/1.php');
但是你能告诉我,如何缩短那个数组吗?谢谢!