QappTikTokUser.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 $device_no;
  17. private $mac;
  18. private $channel_id;
  19. private $uid;
  20. private $register_time;
  21. private $is_report;
  22. /**
  23. * Create a new job instance.
  24. *
  25. * @return void
  26. */
  27. public function __construct(string $device_no, string $mac, int $channel_id, int $uid, string $register_time, bool $is_report = false)
  28. {
  29. $this->device_no = $device_no;
  30. $this->mac = $mac;
  31. $this->channel_id = $channel_id;
  32. $this->uid = $uid;
  33. $this->register_time = $register_time;
  34. $this->is_report = $is_report;
  35. }
  36. /**
  37. * Execute the job.
  38. *
  39. * @return void
  40. */
  41. public function handle()
  42. {
  43. $client = new Client();
  44. $params = [
  45. 'device_no' => $this->device_no,
  46. 'mac' => $this->mac,
  47. 'channel_id' => $this->channel_id,
  48. 'uid' => $this->uid,
  49. 'register_time' => $this->register_time,
  50. 'is_report' => $this->is_report,
  51. 'source' => 'zsy'
  52. ];
  53. $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
  54. $url = 'https://newtrackapi.zhuishuyun.com/api/qappuser/register';
  55. $response = $client->request('post', $url, ['form_params' => $params])->getBody()->getContents();
  56. myLog('new_user_register')->info($response);
  57. $result = json_decode($response);
  58. if ($result) {
  59. if ($result->code != 0) {
  60. myLog('new_user_register')->info($response);
  61. }
  62. }
  63. }
  64. }