twodevs/url-shortener 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

twodevs/url-shortener

最新稳定版本:1.0.2

Composer 安装命令:

composer require twodevs/url-shortener

包简介

This library helps you to generate shortlinks for long url using different URL Shorteners.

README 文档

README

Latest Stable Version License Build Status

This library helps you to generate shortlinks for long url using different URL Shorteners.

Supportet URL Shortener

Installation

The preferred way to install this library is to use Composer.

    $ composer require twodevs/url-shortener ~1.0

Choose a http client support by Ivory HttpAdapter

    $ composer require guzzlehttp/guzzle ~5.0

General Usage

    // Create a client
    $client = new \GuzzleHttp\Client(['defaults' => ['verify' => false]]);
    
    // Create the Adapter
    $adapter = new \Ivory\HttpAdapter\GuzzleHttpHttpAdapter($client);
    
    // Create BitlyShortener
    $shorter = new \TwoDevs\UrlShortener\Provider\BitlyProvider($adapter, ['access_token' => 'your-token']));
    
    // Shorten a long url
    $shortUrl = $shorter->shorten('http://example.org');
    
    // Expand a short url
    $longUrl = $shorter->expand($shortUrl);
    
    var_dump( (string) $shortUrl );
    var_dump( (string) $longUrl );

Using chain provider

    // Create a client
    $client = new \GuzzleHttp\Client(['defaults' => ['verify' => false]]);
    
    // Create the Adapter
    $adapter = new \Ivory\HttpAdapter\GuzzleHttpHttpAdapter($client);
    
    // Create ChainProvider and attach bitly, google shortener and Tiny-Url
    $shorter  = new \TwoDevs\UrlShortener\Provider\ChainProvider();
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\BitlyProvider($adapter, ['access_token' => 'your-token']));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\GoogleProvider($adapter, ['key' => 'your-key']));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\OwlyProvider($adapter, ['key' => 'your-key']));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\TinyUrlProvider($adapter));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\IsgdProvider($adapter));
    $shorter->addProvider(new \TwoDevs\UrlShortener\Provider\VgdUrlProvider($adapter));
    
    // Shorten a long url
    $shortUrl = $shorter->shorten('http://example.org');
    
    // Expand a short url
    $longUrl = $shorter->expand($shortUrl);
    
    var_dump( (string) $shortUrl );
    var_dump( (string) $longUrl );

License

The TwoDevs UrlShortener is under the MIT license. For the full copyright and license information, please read the LICENSE file that was distributed with this source code.

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固