AccessToken.php 474 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace App\Services\WeChat;
  3. use App\Models\Common\TokenModel;
  4. class AccessToken
  5. {
  6. public function get($user_name = null)
  7. {
  8. if (empty($user_name)) {
  9. $user_name = Config('wechat.fpdx.public_id');
  10. }
  11. $data = TokenModel::where('user_name', $user_name)->first();
  12. if ($data) {
  13. return $data->access_token;
  14. } else {
  15. throw new WeChatException("公众号异常", 500);
  16. }
  17. }
  18. }