Test.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\index\controller;
  3. use think\Controller;
  4. use \GatewayWorker\Lib\Gateway;
  5. use app\common\library\Tlssigapiv2;
  6. class Test extends Controller
  7. {
  8. public function test(){
  9. $Gateway = new Gateway();
  10. $Gateway::$registerAddress = '127.0.0.1:2345';
  11. $Gateway::sendToAll('来自服务端的主动推送'.date('Y-m-d H:i:s'));
  12. }
  13. public function ip(){
  14. $ipaddress = ip_to_address();
  15. echo $ipaddress;
  16. }
  17. public function newip(){
  18. $ipaddress = newip_to_address();
  19. echo $ipaddress;
  20. }
  21. public function im(){
  22. $sdkappid = '1400818730';
  23. $sdkappkey = 'f31aa80a36cef72829fbcdcb10aa2aadcea2944787f2b268d46021e67711326b';
  24. $usersig = $this->usersig($sdkappid,$sdkappkey);
  25. $random = rand(10000000,99999999);
  26. $url = 'https://console.tim.qq.com/v4/open_msg_svc/get_history?sdkappid='.$sdkappid.'&identifier=administrator&usersig='.$usersig.'&random='.$random.'&contenttype=json';
  27. $data = [
  28. 'ChatType' => 'Group',
  29. // 'ChatType' => 'C2C',
  30. 'MsgTime' => date('YmdH',strtotime('-1 Days')),
  31. // 'MsgTime' => date('YmdH',strtotime('-60 Hours')),
  32. ];
  33. dump($data);
  34. $jsonStr = json_encode($data);
  35. $header = array(
  36. 'Content-Type: application/json; charset=utf-8',
  37. 'Content-Length: ' . strlen($jsonStr)
  38. );
  39. $rs = curl_post($url,$jsonStr,$header);
  40. dump($rs);
  41. }
  42. private function usersig($sdkappid,$key){
  43. $api = new TLSSigAPIv2($sdkappid,$key );
  44. $sig = $api->genUserSig('administrator');
  45. return $sig;
  46. }
  47. public function test_redis(){
  48. $redis = new Redis();
  49. $redisconfig = config("redis");
  50. $redis->connect($redisconfig["host"], $redisconfig["port"]);
  51. if ($redisconfig['redis_pwd']) {
  52. $redis->auth($redisconfig['redis_pwd']);
  53. }
  54. if($redisconfig['redis_selectdb'] > 0){
  55. $redis->select($redisconfig['redis_selectdb']);
  56. }
  57. $party_id = 141;
  58. $res = $redis->hGetAll("online_".$party_id);
  59. dump($res);
  60. }
  61. }