ShopCollectService.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: weifeng
  5. * Date: 2020-01-06
  6. * Time: 15:51
  7. *
  8. * .--, .--,
  9. * ( ( \.---./ ) )
  10. * '.__/o o\__.'
  11. * {= ^ =}
  12. * > - <
  13. * / \
  14. * // \\
  15. * //| . |\\
  16. * "'\ /'"_.-~^`'-.
  17. * \ _ /--' `
  18. * ___)( )(___
  19. * (((__) (__))) 梦之所想,心之所向.
  20. */
  21. namespace app\common\services;
  22. use Ixudra\Curl\Facades\Curl;
  23. class ShopCollectService
  24. {
  25. public $url;
  26. public function __construct()
  27. {
  28. $this->url = 'https://s.yunzmall.com';
  29. //$this->url = 'http://www.wfmarket.com'; //测试
  30. }
  31. public function handle()
  32. {
  33. $host_message = json_decode(file_get_contents(base_path('static/yunshop/js/host.js')), true);
  34. $host = $host_message['host']?:'';
  35. $key = $host_message['key']?:'';
  36. $secret = $host_message['secret']?:'';
  37. $data = [
  38. 'host' => $host,
  39. 'plugins' => $this->getPlugins(),
  40. 'key' => $key,
  41. 'secret' => $secret,
  42. ];
  43. $url = $this->url . '/api/plugin-collect/plugin-collect';
  44. $result = \Curl::to($url)
  45. ->withData($data)
  46. ->asJsonResponse(true)
  47. ->post();
  48. if ($result['result'] != 1) {
  49. \Log::debug('------授权系统请求获取插件信息接口失败------', $result);
  50. }
  51. }
  52. public function getPlugins()
  53. {
  54. $plugin_name = [];
  55. $plugins = app('plugins')->getPlugins()->toArray();
  56. foreach ($plugins as $plugin) {
  57. $plugin_name[] = $plugin['name'];
  58. }
  59. return $plugin_name;
  60. }
  61. }