TikTokUserRegister.php 2.0 KB

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