12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use Redis;
- use think\Db;
- /**
- * 环信接口
- */
- class Easemob extends Api
- {
- protected $noNeedLogin = ["callback"];
- protected $noNeedRight = ['*'];
- /**
- * 回调
- */
- public function callback() {
- $this->notify_log_start();
- $input = file_get_contents("php://input"); // 主题信息
- $input = json_decode($input,true);
- }
- //异步日志
- private function notify_log_start($paytype = 'easemob'){
- //记录支付回调数据
- ignore_user_abort(); // run script in background
- set_time_limit(30);
- // 日志文件 start
- $log_base_dir = '../paylog/'.$paytype.'/';
- if (!is_dir($log_base_dir))
- {
- mkdir($log_base_dir, 0770, true);
- @chmod($log_base_dir, 0770);
- }
- $notify_file = $log_base_dir.'notify.txt';
- if(!file_exists($notify_file)) {
- @touch($notify_file);
- @chmod($notify_file, 0770);
- }
- if(filesize($notify_file)>5242880)//大于5M自动切换
- {
- rename($notify_file, $log_base_dir.'notify_'.date('Y_m_d_H_i_s').'.txt');
- }
- if(!file_exists($notify_file)) {
- @touch($notify_file);
- @chmod($notify_file, 0770);
- }
- // 日志文件 end
- //开始写入
- $xml = file_get_contents("php://input");
- file_put_contents($notify_file, "\r\n\r\n".date('Y-m-d H:i:s')." [notify][入口接收php://input流原始数据] \n".$xml, FILE_APPEND);
- ini_set('display_errors','On');
- return $notify_file;
- }
- }
|