rezzza/shorty

为你的长网址提供内衣

v1.3.1 2015-12-18 08:53 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:34:48 UTC


README

https://poser.pugx.org/rezzza/Shorty/version.png https://travis-ci.org/rezzza/Shorty.png?branch=master https://insight.sensiolabs.com/projects/92606d9e-f7ee-48a9-adf0-d7d7cd4d8918/mini.png

为你的长网址提供内衣

安装

使用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适配器。