Test.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Console\Commands\WechatPlatform;
  3. use App\Jobs\WechatPlatform\GZHSendKFMessage;
  4. use App\Service\Util\Support\Trace\TraceContext;
  5. use App\Service\WechatPlatform\WechatPlatformConstService;
  6. use EasyWeChat\Factory;
  7. use Illuminate\Console\Command;
  8. use Illuminate\Support\Facades\Cache;
  9. use Illuminate\Support\Facades\DB;
  10. class Test extends Command
  11. {
  12. /**
  13. * The name and signature of the console command.
  14. *
  15. * @var string
  16. */
  17. protected $signature = 'WechatPlatform:Test';
  18. /**
  19. * The console command description.
  20. *
  21. * @var string
  22. */
  23. protected $description = 'Command description';
  24. /**
  25. * Execute the console command.
  26. */
  27. public function handle()
  28. {
  29. $config = [
  30. 'app_id' => 'wxf313b3506bac2647',
  31. 'secret' => 'aaf348571cbc5d554e4de1bcd3cb0342',
  32. 'token' => 'jXP3Cdl6GofhWVsQTtgwLv2tMZG9nHlPgErZm6ixaSl',
  33. 'aes_key' => 'GtG7s1v7QV8kRfpWeGmDnwhwdPPKSrA35rIhmrwenpq',
  34. 'http' => [
  35. 'max_retries' => 1,
  36. 'retry_delay' => 500,
  37. 'timeout' => 5.0,
  38. ],
  39. ];
  40. $openPlatform = Factory::openPlatform($config);
  41. $openPlatform->rebind('cache', Cache::store('redis'));
  42. $officialAccount = $openPlatform->officialAccount('wxebcb86ec4b80eaca',
  43. 'refreshtoken@@@pOdN-RBZ1f475kZxXM66IcG2keHkv8V0mDs97JYa2TQ');
  44. $res = $officialAccount->customer_service->message('hello, '. date('Y-m-d H:i:s'))
  45. ->to('oHhd20dzCcfVjWt4OcGzFWISp6A4')
  46. ->send();
  47. dump($res);
  48. }
  49. }