QappTikTokUser.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App\Jobs;
  3. use App\Consts\SysConsts;
  4. use GuzzleHttp\Client;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Queue\SerializesModels;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. /**
  11. * 快应用抖音推广用户
  12. */
  13. class QappTikTokUser implements ShouldQueue
  14. {
  15. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  16. private $ip;
  17. private $device_no;
  18. private $mac;
  19. private $channel_id;
  20. private $uid;
  21. private $register_time;
  22. private $is_report;
  23. /**
  24. * Create a new job instance.
  25. *
  26. * @return void
  27. */
  28. public function __construct(string $ip, string $device_no, string $mac, int $channel_id, int $uid, string $register_time, bool $is_report = false)
  29. {
  30. $this->ip = $ip;
  31. $this->device_no = $device_no;
  32. $this->mac = $mac;
  33. $this->channel_id = $channel_id;
  34. $this->uid = $uid;
  35. $this->register_time = $register_time;
  36. $this->is_report = $is_report;
  37. }
  38. /**
  39. * Execute the job.
  40. *
  41. * @return void
  42. */
  43. public function handle()
  44. {
  45. $client = new Client();
  46. $params = [
  47. 'ip' => $this->ip,
  48. 'device_no' => $this->device_no,
  49. 'mac' => $this->mac ?? '',
  50. 'channel_id' => $this->channel_id,
  51. 'uid' => $this->uid,
  52. 'register_time' => $this->register_time,
  53. 'is_report' => (string)$this->is_report,
  54. 'source' => 'zsy'
  55. ];
  56. $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
  57. $url = 'https://newtrackapi.zhuishuyun.com/api/qappuser/register';
  58. $response = $client->request('post', $url, ['form_params' => $params])->getBody()->getContents();
  59. myLog('qapp_user_register')->info($response);
  60. $result = json_decode($response);
  61. if ($result) {
  62. if ($result->code != 0) {
  63. myLog('qapp_user_register')->info($response);
  64. }
  65. }
  66. }
  67. }