HwPushTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace App\Console\Commands\Push;
  3. use App\Consts\PushConst;
  4. use App\Libs\Push\HuaWei\Admin\Constants;
  5. use App\Libs\Push\HuaWei\HwPushCommon;
  6. use App\Libs\Push\HuaWei\PushMsgCommon;
  7. use Illuminate\Console\Command;
  8. class HwPushTest extends Command
  9. {
  10. /**
  11. * The name and signature of the console command.
  12. *
  13. * @var string
  14. */
  15. protected $signature = 'push:hw:test';
  16. /**
  17. * The console command description.
  18. *
  19. * @var string
  20. */
  21. protected $description = 'test push';
  22. /**
  23. * Execute the console command.
  24. *
  25. * @return mixed
  26. */
  27. public function handle()
  28. {
  29. $appId = '102612543';
  30. $appSecret = '07c896089f432163421923bdcab83a8da9d386274be43e61d510c27f56c23269';
  31. $pushToken = 'AN0R08PKJjTJvCTRCL8hATh5ZxIVHQQOhpQ1JkpyRBjG25pRKbBckpUntQYBLpXNb2SFj8_bGb18uMeCT7KY5ehosiWZlopKUIphPYqeWKJeQcHGrn2fPKUsFEM-72X5Zg';
  32. $fastAppPushCommon = new HwPushCommon($appId, $appSecret);
  33. $fastAppPushCommon->setToken([$pushToken]);
  34. // $fastAppPushCommon->subscribeTopic(PushConst::TOPIC_ALL, [$pushToken]);
  35. // $fastAppPushCommon->unSubscribeTopic(PushConst::TOPIC_ALL, [$pushToken]);
  36. // $result = $fastAppPushCommon->subscribeList($pushToken);
  37. // $result = $fastAppPushCommon->queryPushToken($pushToken);
  38. $result = $fastAppPushCommon->sendPushMessage('我是标题', '我是内容', '/');
  39. dd($result);
  40. // $testPushMsgSample = new PushMsgCommon();
  41. // $testPushMsgSample->sendPushMsgMessageByMsgType(Constants::PUSHMSG_FASTAPP_MSG_TYPE);
  42. // $message = '{
  43. // "data": "{\"pushtype\":1,\"pushbody\":{\"messageId\":\"111110001\",\"data\":\"test pass-through msg\"}}",
  44. // "ssss":"{k1:v1}",
  45. // "android": {
  46. // "collapse_key": -1,
  47. // "urgency": "HIGH",
  48. // "ttl": "1448s",
  49. // "bi_tag": "Trump",
  50. // "fast_app_target": 1
  51. // },
  52. // "token": [
  53. // *push_token*
  54. // ]
  55. //}';
  56. //
  57. //
  58. // $message = str_ireplace("*push_token*", '"' . $testPushMsgSample->fast_push_token . '"', $message);
  59. // $testPushMsgSample->sendPushMsgRealMessage(json_decode($message), Constants::PUSHMSG_FASTAPP_MSG_TYPE);
  60. }
  61. }