抖音小程序

AutoUploadMaterialToDouYin.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Log;
  4. use App\Models\Material;
  5. use App\Service\MaterialService;
  6. use App\Support\EmailQueue;
  7. use Illuminate\Console\Command;
  8. use PharIo\Manifest\Email;
  9. class AutoUploadMaterialToDouYin extends Command
  10. {
  11. /**
  12. * The name and signature of the console command.
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'AutoUploadMaterialToDouYin';
  17. /**
  18. * The console command description.
  19. *
  20. * @var string
  21. */
  22. protected $description = '定时上传素材到抖音';
  23. public function handle()
  24. {
  25. \DB::connection()->disableQueryLog();
  26. $this->info(date('m-d H:i:s') . ' 开始整理');
  27. try{
  28. # 查询待同步的素材列表
  29. $materialList = Material::getUnUploadMaterialList();
  30. if($materialList->isEmpty()) {
  31. return false;
  32. }
  33. # 上传视频到抖音
  34. foreach($materialList as $materialInfo) {
  35. MaterialService::uploadMaterialToDouYin($materialInfo->id, $materialInfo->app_id, $materialInfo->resource_type
  36. , $materialInfo->oss_url, $materialInfo->title, $materialInfo->desc);
  37. }
  38. } catch (\Exception $exception) {
  39. Log::logError('定时上传素材到抖音程序异常', [
  40. 'file' => $exception->getFile(),
  41. 'line' => $exception->getLine(),
  42. 'msg' => $exception->getMessage(),
  43. 'trace' => $exception->getTraceAsString()
  44. ], 'autoUploadMaterialToDouYin-exception');
  45. EmailQueue::rPush('定时上传素材到抖音程序异常', $exception->getFile().'('.$exception->getLine().')'
  46. .':'.$exception->getMessage(),['song.shen@kuxuan-inc.com'], '抖音短剧');
  47. }
  48. $this->info(date('m-d H:i:s') . ' 整理结束');
  49. }
  50. }