UserTrait.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wangzhiqiang
  5. * Date: 2019/5/5
  6. * Time: 17:11
  7. */
  8. namespace App\Traits;
  9. use Tymon\JWTAuth\Facades\JWTAuth;
  10. trait UserTrait
  11. {
  12. public function getUserInfo() {
  13. try {
  14. $sign = generateSign([], config('customer.app_secret'));
  15. $url = config("customer.app_service_url").'/user/userInfo';
  16. $array = [
  17. 'json' => ['sign' => $sign], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
  18. ];
  19. return http($url,$array);
  20. } catch (\Exception $e) {
  21. return [];
  22. }
  23. }
  24. public function getFollowStatus($uid, $followUid) {
  25. try {
  26. $sign = generateSign([], config('customer.app_secret'));
  27. $url = config("customer.app_service_url").'/user/v2/follow/checkStatus';
  28. $array = [
  29. 'json' => ['sign' => $sign, 'uid' => $followUid, 'follow_uid' => $uid], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
  30. ];
  31. return http($url,$array,'get');
  32. } catch (\Exception $e) {
  33. return [];
  34. }
  35. }
  36. }