BehaviorRepository.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\Behavior;
  4. use GuzzleHttp\Client;
  5. use GuzzleHttp\Exception\RequestException;
  6. use Tymon\JWTAuth\Facades\JWTAuth;
  7. /**
  8. * Created by PhpStorm.
  9. * User: durong
  10. * Date: 2019/6/10
  11. * Time: 上午11:11
  12. */
  13. class BehaviorRepository
  14. {
  15. public function __construct(Behavior $behavior)
  16. {
  17. $this->behavior = $behavior;
  18. }
  19. public function index($request)
  20. {
  21. try {
  22. $app = config('constants.VIRUS_APP_ID');
  23. $signKey = [
  24. 'app' => config('constants.VIRUS_APP_ID')
  25. ];
  26. ksort($signKey);
  27. $signKey = urldecode(http_build_query($signKey));
  28. $sign = md5(config('constants.VIRUS_APP_SECRET') . $signKey);
  29. $url = config("customer.manage_service_url") . '/virus/behaviorList';
  30. $array = [
  31. 'json' => ['app' => $app,'sign' => $sign], 'query' => [], 'http_errors' => false, 'headers' => ['Authorization' => "Bearer " . JWTAuth::getToken()]
  32. ];
  33. return http($url, $array, 'get');
  34. } catch (\Exception $e) {
  35. return [];
  36. }
  37. }
  38. }