芝麻web文件管理V1.00
编辑当前文件:/home/shaabmuni/public_html/public/crm/vendor/mremi/url-shortener/README.md
URL shortener library ===================== This library allows you to shorten a URL, reverse is also possible. [](https://insight.sensiolabs.com/projects/c4e06c9d-547c-47bb-8abb-fccc68b7df7a) [](https://travis-ci.org/mremi/UrlShortener) [](https://packagist.org/packages/mremi/url-shortener) [](https://packagist.org/packages/mremi/url-shortener) [](https://scrutinizer-ci.com/g/mremi/UrlShortener/) [](https://scrutinizer-ci.com/g/mremi/UrlShortener/) **Basic Docs** * [Installation](#installation) * [Bit.ly API](#bitly-api) * [Google API](#google-api) * [Chain providers](#chain-providers) * [Retrieve link](#retrieve-link) * [Contribution](#contribution)
## Installation Only 1 step: ### Download UrlShortener using composer Add UrlShortener in your composer.json: ```js { "require": { "mremi/url-shortener": "dev-master" } } ``` Now tell composer to download the library by running the command: ``` bash $ php composer.phar update mremi/url-shortener ``` Composer will install the library to your project's `vendor/mremi` directory.
## Bit.ly API ```php setLongUrl('http://www.google.com'); $bitlyProvider = new BitlyProvider( new OAuthClient('username', 'password'), array('connect_timeout' => 1, 'timeout' => 1) ); $bitlyProvider->shorten($link); $bitlyProvider->expand($link); ```
## Google API ```php setLongUrl('http://www.google.com'); $googleProvider = new GoogleProvider( 'api_key', array('connect_timeout' => 1, 'timeout' => 1) ); $googleProvider->shorten($link); $googleProvider->expand($link); ```
## Chain providers ```php addProvider($bitlyProvider); $chainProvider->addProvider($googleProvider); // add yours... $link = new Link; $link->setLongUrl('http://www.google.com'); $chainProvider->getProvider('bitly')->shorten($link); $chainProvider->getProvider('google')->expand($link); ```
## Retrieve link You can retrieve some links using these finders: ```php findOneByProviderAndShortUrl('bitly', 'http://bit.ly/ze6poY'); $expanded = $linkManager->findOneByProviderAndLongUrl('google', 'http://www.google.com'); ```
## Contribution Any question or feedback? Open an issue and I will try to reply quickly. A feature is missing here? Feel free to create a pull request to solve it! I hope this has been useful and has helped you. If so, share it and recommend it! :) [@mremitsme](https://twitter.com/mremitsme)