for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace tinymeng\OAuth2\Connector;
trait GatewayTrait
{
/**
* @var 缓存处理
缓存处理
0
*/
protected $cache;
* Description: 执行GET请求操作
* @author: JiaMeng <[email protected]>
* Updater:
* @param $url
* @param array $params
* @param array $headers
* @return string
protected function get($url, $params = [], $headers = [])
return \tinymeng\tools\HttpRequest::httpGet($url, $params,$headers);
}
* Description: 执行POST请求操作
* @return mixed
protected function post($url, $params = [], $headers = [])
$headers[] = 'Accept: application/json';//GitHub需要的header
return \tinymeng\tools\HttpRequest::httpPost($url, $params,$headers);
public function setCache($cache)
$this->cache = $cache;
return $this;
protected function getTokenFromCache($key)
return $this->cache ? $this->cache->get($key) : null;
protected function setTokenToCache($key, $token, $expires = 7200)
if ($this->cache) {
$this->cache->set($key, $token, $expires);