41 lines
909 B
PHP
41 lines
909 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the overtrue/wechat.
|
|
*
|
|
* (c) overtrue <i@overtrue.me>
|
|
*
|
|
* This source file is subject to the MIT license that is bundled
|
|
* with this source code in the file LICENSE.
|
|
*/
|
|
|
|
namespace TuzhiEasyWeChat\BasicService\Url;
|
|
|
|
use TuzhiEasyWeChat\Kernel\BaseClient;
|
|
|
|
/**
|
|
* Class Client.
|
|
*
|
|
* @author overtrue <i@overtrue.me>
|
|
*/
|
|
class Client extends BaseClient
|
|
{
|
|
/**
|
|
* Shorten the url.
|
|
*
|
|
* @return \Psr\Http\Message\ResponseInterface|\TuzhiEasyWeChat\Kernel\Support\Collection|array|object|string
|
|
*
|
|
* @throws \TuzhiEasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
*/
|
|
public function shorten(string $url)
|
|
{
|
|
$params = [
|
|
'action' => 'long2short',
|
|
'long_url' => $url,
|
|
];
|
|
|
|
return $this->httpPostJson('cgi-bin/shorturl', $params);
|
|
}
|
|
}
|