<?php namespace app\index\controller; use think\Controller; use \GatewayWorker\Lib\Gateway; use app\common\library\Tlssigapiv2; class Test extends Controller { public function test(){ $Gateway = new Gateway(); $Gateway::$registerAddress = '127.0.0.1:2345'; $Gateway::sendToAll('来自服务端的主动推送'.date('Y-m-d H:i:s')); } public function ip(){ $ipaddress = ip_to_address(); echo $ipaddress; } public function newip(){ $ipaddress = newip_to_address(); echo $ipaddress; } public function im(){ $sdkappid = '1400818730'; $sdkappkey = 'f31aa80a36cef72829fbcdcb10aa2aadcea2944787f2b268d46021e67711326b'; $usersig = $this->usersig($sdkappid,$sdkappkey); $random = rand(10000000,99999999); $url = 'https://console.tim.qq.com/v4/open_msg_svc/get_history?sdkappid='.$sdkappid.'&identifier=administrator&usersig='.$usersig.'&random='.$random.'&contenttype=json'; $data = [ 'ChatType' => 'Group', // 'ChatType' => 'C2C', 'MsgTime' => date('YmdH',strtotime('-1 Days')), // 'MsgTime' => date('YmdH',strtotime('-60 Hours')), ]; dump($data); $jsonStr = json_encode($data); $header = array( 'Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($jsonStr) ); $rs = curl_post($url,$jsonStr,$header); dump($rs); } private function usersig($sdkappid,$key){ $api = new TLSSigAPIv2($sdkappid,$key ); $sig = $api->genUserSig('administrator'); return $sig; } public function test_redis(){ $redis = new Redis(); $redisconfig = config("redis"); $redis->connect($redisconfig["host"], $redisconfig["port"]); if ($redisconfig['redis_pwd']) { $redis->auth($redisconfig['redis_pwd']); } if($redisconfig['redis_selectdb'] > 0){ $redis->select($redisconfig['redis_selectdb']); } $party_id = 141; $res = $redis->hGetAll("online_".$party_id); dump($res); } }