string=$string; $infos->save(); $result=mb_strpos($string,'http'); $m=mb_strpos($string,'CL'); if ($result === false) { Gateway::sendToClient($client_id,$string); die(); }else{ if ($m===false){ Gateway::sendToClient($client_id,$string); die(); } } Log::info($result); try { $file_name=public_path().'/txtlog/'.date('y-m-d').'.txt'; if (file_exists($file_name)){ $file = fopen($file_name, "a"); $content = $string . PHP_EOL; // 添加换行符 fwrite($file, $content); fclose($file); }else{ $filename =$file_name; $file = fopen($filename, "w"); if ($file) { // 更改文件权限为可读可写 chmod($filename, 0666); $content = $string . PHP_EOL; // 添加换行符 $file = fopen($file_name, "a"); fwrite($file, $content); fclose($file); echo "文件已创建并写入内容,并更改权限为可读可写。"; } else { echo "无法创建文件。"; } } }catch (\Exception $exception){ $file_name=public_path().'/txtlog/2023-06-20.txt'; $file = fopen($file_name, "a"); $content = '异常'.$string . PHP_EOL; // 添加换行符 fwrite($file, $content); fclose($file); } $url='http://fangw.jiuweiyun.cn/api/getinfo'; $client=new Client(); $data = [ 'sign' => 'AD253SghasdklasSdafAGAdsa541', 'string' => $string, ]; $re=$client->post($url,[ 'form_params' => $data, ]); $re=$re->getBody()->getContents(); $re=json_decode($re); if ($re->status==0){ Log::error($re->message); Gateway::sendToClient($client_id,json_encode(['msg'=>'失败了','code'=>0000])); }else{ $infos->status=1; $infos->save(); } } }