Ding.php 784 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Http\Controllers\Core;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Support\Facades\App;
  5. class Ding extends Controller
  6. {
  7. /**
  8. * @param array $data
  9. */
  10. public static function robot(array $data)
  11. {
  12. if (App::environment() == 'local') {
  13. return;
  14. }
  15. $url = "https://oapi.dingtalk.com/robot/send?access_token=3eecb1bcb942d7aa4776613faa1dce142923ed6964d04ac66f803c643ed8f653";
  16. $data = [
  17. "msgtype" => 'markdown',
  18. 'markdown' => [
  19. 'title' => $data['title'],
  20. 'text' => "#### **{$data['title']}** \n {$data['text']}"
  21. ],
  22. 'isAtAll' => true
  23. ];
  24. \Curl::to($url)->withData($data)->asJson('true')->post();
  25. }
  26. }