Files
kiri-wchat/wchat/qq/Account.php
T
2023-07-11 21:04:33 +08:00

37 lines
697 B
PHP

<?php
/**
* Created by PhpStorm.
* User: whwyy
* Date: 2018/4/19 0019
* Time: 16:12
*/
namespace wchat\qq;
use Kiri\Client;
use wchat\common\Result;
class Account extends SmallProgram
{
/**
* @param string $code
* @return Result
*/
public function login(string $code): Result
{
$param['appid'] = $this->config->getAppid();
$param['secret'] = $this->config->getAppsecret();
$param['js_code'] = $code;
$param['grant_type'] = 'authorization_code';
$client = new Client('api.q.qq.com', 443, true);
$client->withHeader(['Content-Type' => 'application/json']);
$client->get('sns/jscode2session', $param);
$client->close();
return Result::init($client);
}
}