QappTikTokUser.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Jobs\QappTikTok;
  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 $reportParams;
  17. /**
  18. * QappTikTokUser constructor.
  19. * @param QappTikTokUserRequest $reportParams
  20. */
  21. public function __construct(QappTikTokUserRequest $reportParams)
  22. {
  23. $this->reportParams = $reportParams;
  24. }
  25. /**
  26. * Execute the job.
  27. * @throws \GuzzleHttp\Exception\GuzzleException
  28. */
  29. public function handle()
  30. {
  31. $client = new Client();
  32. $params = [
  33. 'ip' => $this->reportParams->ip,
  34. 'device_no' => $this->reportParams->device_no,
  35. 'mac' => $this->reportParams->mac ?? '',
  36. 'channel_id' => (int)$this->reportParams->channel_id,
  37. 'uid' => (int)$this->reportParams->uid,
  38. 'register_time' => $this->reportParams->register_time,
  39. 'is_report' => (string)$this->reportParams->is_report,
  40. 'source' => 'zsy',
  41. 'send_order_id' => $this->reportParams->send_order_id,
  42. ];
  43. $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
  44. $url = env('TIKTOK_API_URL').'api/qappuser/register';
  45. $response = $client->request('post', $url, ['form_params' => $params])->getBody()->getContents();
  46. myLog('qapp_user_register')->info($response);
  47. $result = json_decode($response);
  48. if ($result) {
  49. if ($result->code != 0) {
  50. myLog('qapp_user_register')->info($response);
  51. }
  52. }
  53. }
  54. }