generated from panliang/owl-admin-starter
26 lines
580 B
PHP
26 lines
580 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use EasyWeChat\OfficialAccount\AccessToken;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
/**
|
|
* 自定义微信AccessToken
|
|
*/
|
|
class WechatOfficialAccessToken extends AccessToken
|
|
{
|
|
public function getToken(): string
|
|
{
|
|
if ($url = config('easywechat.official_account.access_token_url')) {
|
|
$response = Http::post($url);
|
|
if ($response->successful()) {
|
|
$token = data_get($response->json(), 'data.token');
|
|
return $token;
|
|
}
|
|
}
|
|
|
|
return parent::getToken();
|
|
}
|
|
}
|