NewTikTokUser.php 1.8 KB

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