Bit.lyのAPIを叩くライブラリをopenpear.orgで公開した
今まで作っていたclassを元に書き直してあります。
今回は、bit.lyとj.mp両方に一つのライブラリで対応できるようにしてあり
今のところshortenとexpandのみを実装しています。
Services_Bitly \ Package \ Openpear
インストール
sudo pear channel-discover openpear.org sudo pear install openpear/Services_Bitly-alpha
使い方
<?php require_once 'Services/Bitly.php'; $login = 'Bitlyのアカウント'; $apikey = 'BitlyのAPI Key'; $bitly = new Services_Bitly($login,$apikey); $shorten = $bitly->shorten("http://openpear.org"); $bitly = new Services_Bitly($login,$apikey); $expand = $bitly->expand($shorten); // j.mp対応 $bitly = new Services_Bitly($login,$apikey); $bitly->changeBaseDomain(); $shorten = $bitly->shorten("http://openpear.org"); $bitly = new Services_Bitly($login,$apikey); $bitly->changeBaseDomain(); $expand = $bitly->expand($shorten);