1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace App\Jobs;
- use App\Consts\SysConsts;
- use GuzzleHttp\Client;
- use Illuminate\Bus\Queueable;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- /**
- * 抖音用户推送数据
- */
- class TikTokUserRegister implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- private $uid;
- private $ip;
- private $ua;
- private $app_id;
- private $open_id;
- private $account_id;
- private $time;
- /**
- * Create a new job instance.
- * @param int $uid
- * @param string $type 类型
- * @return void
- */
- public function __construct(string $ip, string $ua, string $app_id, string $open_id, string $account_id, int $uid, string $time)
- {
- $this->uid = $uid;
- $this->ip = $ip;
- $this->ua = $ua;
- $this->app_id = $app_id;
- $this->open_id = $open_id;
- $this->account_id = $account_id;
- $this->time = $time;
- }
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- $client = new Client();
- $params = [
- 'uid' => $this->uid,
- 'ip' => $this->ip,
- 'ua' => $this->ua,
- 'app_id' => $this->app_id,
- 'open_id' => $this->open_id,
- 'account_id' => $this->account_id,
- 'time' => $this->time,
- 'source' => 'wdy'
- ];
- $params['sign'] = _sign($params, SysConsts::TIKTOK_KEY);
- $url = 'https://newtrackapi.zhuishuyun.com/api/user/tiktokUserPush';
- $response = $client->request('post', $url, ['form_params' => $params])->getBody()->getContents();
- myLog('tiktok_push_register')->info($response);
- $result = json_decode($response);
- if ($result) {
- if ($result->code != 0) {
- myLog('tiktok_push_register')->info($response);
- }
- }
- }
- }
|