DelWechatMaterial.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Console\Commands\ActionTrigger\BatchWechatMaterial;
  3. use App\Http\Controllers\WechatController;
  4. use Illuminate\Console\Command;
  5. use DB;
  6. /**
  7. * 删除微信素材
  8. *
  9. */
  10. class DelWechatMaterial extends Command
  11. {
  12. /**
  13. * The name and signature of the console command.
  14. *
  15. * @var string
  16. */
  17. protected $signature = 'ActionTrigger:del_zs_wechat_material {data}';
  18. /**
  19. * The console command description.
  20. *
  21. * @var string
  22. */
  23. protected $description = '删除微信素材';
  24. /**
  25. * Create a new command instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. }
  33. /**
  34. * Execute the console command.
  35. *
  36. * @return mixed
  37. */
  38. public function handle()
  39. {
  40. \Log::info('del_zs_wechat_material start:');
  41. $data = $this->argument('data');
  42. try{
  43. $this->start($data['data']);
  44. }catch(\Exception $e){
  45. \Log::error($e->getMessage());
  46. }
  47. \Log::info('del_zs_wechat_material end:');
  48. }
  49. public function start($data){
  50. \Log::info('$data');\Log::info($data);
  51. //检查参数
  52. if(!($data['appid']&&$data['media_id'])){
  53. \Log::info('params_empty');
  54. return;
  55. }
  56. //微信删除素材接口
  57. try{
  58. $WechatController = new WechatController($data['appid']);
  59. $res = $WechatController->app->material->delete($data['media_id']);
  60. \Log::info($res);
  61. }catch(\Exception $e){
  62. \Log::error($e->getMessage());
  63. }
  64. return;
  65. }
  66. }