dotzero / googl
此包已被废弃,不再维护。未建议替换包。
一个用于通过Google URL Shortener API生成缩短URL的PHP5库
0.2.0
2016-04-11 09:34 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 4.0.*
This package is auto-updated.
Last update: 2022-06-04 08:41:42 UTC
README
一个用于通过Google URL Shortener API生成缩短URL的PHP5库。
用法
强烈建议使用Google API密钥。获取API密钥请遵循说明。
缩短URL
使用Google URL Shortener API缩短长URL
try { $googl = new \dotzero\Googl('YOUR_GOOGLE_API'); echo $googl->shorten('http://github.com'); } catch (\dotzero\GooglException $e) { printf('Error (%d): %s', $e->getCode(), $e->getMessage()); }
展开URL
使用Google URL Shortener API展开短URL
try { $googl = new \dotzero\Googl('YOUR_GOOGLE_API'); echo $googl->expand('http://goo.gl/KkZ8'); } catch (\dotzero\GooglException $e) { printf('Error (%d): %s', $e->getCode(), $e->getMessage()); }
安装
通过Composer
$ composer require dotzero/googl
不通过Composer
使用git clone https://github.com/dotzero/googl-php/
克隆项目,并使用require_once("googl-php/src/Googl.php");
包含源文件。
测试
首先安装依赖,然后可以运行
GOOGLE_API=YOUR_GOOGLE_API vendor/bin/phpunit
许可证
在MIT许可证下授权: https://open-source.org.cn/licenses/mit-license.php