1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-23 03:50:56 +08:00
xiaochong0302 3c906cb6c7 1.修复验证码
2.增加第三方登录
2020-04-17 18:53:04 +08:00

54 lines
1.1 KiB
PHP

<?php
namespace App\Library;
use GuzzleHttp\Client as HttpClient;
abstract class OAuth
{
protected $appId;
protected $appSecret;
protected $redirectUri;
protected $accessToken;
protected $openId;
public function __construct($appId, $appSecret, $redirectUri)
{
$this->appId = $appId;
$this->appSecret = $appSecret;
$this->redirectUri = $redirectUri;
}
public function httpGet($uri, $params = [], $headers = [])
{
$client = new HttpClient();
$options = ['query' => $params, 'headers' => $headers];
$response = $client->get($uri, $options);
return $response->getBody();
}
public function httpPost($uri, $params = [], $headers = [])
{
$client = new HttpClient();
$options = ['query' => $params, 'headers' => $headers];
$response = $client->post($uri, $options);
return $response->getBody();
}
abstract public function getAuthorizeUrl();
abstract public function getAccessToken($code);
abstract public function getOpenId($accessToken);
abstract public function getUserInfo($accessToken, $openId);
}