rezzza / shorty
为您的长URL提供内衣
v1.3.1
2015-12-18 08:53 UTC
Requires
- php: >=5.3.3
- symfony/property-access: ~2.2|~3.0
Requires (Dev)
- atoum/atoum: ~2.0
- guzzle/guzzle: 3.*
Suggests
- guzzle/http: Guzzle HTTP Adapter
This package is not auto-updated.
Last update: 2024-09-14 14:34:48 UTC
README
为您的长URL提供内衣
安装
使用 Composer 安装: rezzza/shorty
.
在您的 composer.json 中应该有
{ "require": { "rezzza/shorty": "1.0.*" } }
需求
Shorty 需要 Guzzle.
使用方法
使用 Google 短网址的示例
$googleShortener = new \Rezzza\Shorty\Provider\Google(); $googleShortener->setHttpAdapter(new \Rezzza\Shorty\Http\GuzzleAdapter()); // or // $googleShortener->setHttpAdapter(new \Rezzza\Shorty\Http\CurlAdapter()); $shortUrl = $googleShortener->shorten('http://www.verylastroom.com/'); $longUrl = $googleShortener->expand('http://goo.gl/YY5Tz');
使用 Chain 短网址的示例
$chainShortener = new \Rezzza\Shorty\Provider\Chain(); $chainShortener->addProvider($googleShortener); // see example above $chainShortener->addProvider($bitlyShortener); $shortUrl = $chainShortener->shorten('http://www.verylastroom.com/'); $longUrl = $chainShortener->expand('http://goo.gl/YY5Tz');
单元测试
您可以使用以下命令运行测试
bin/atoum -d tests/units
发布说明
1.1.0
- 添加了 Chain 提供程序。
1.0.0
- 添加了 Google 网址缩短器。
- 添加了 Bitly 网址缩短器。
- 添加了 Curl Http 适配器。