9
This commit is contained in:
Executable
+57
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace app\command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use support\think\Db;
|
||||
use isszz\hashids\facade\Hashids;
|
||||
use function GuzzleHttp\json_encode;
|
||||
|
||||
class User extends Command
|
||||
{
|
||||
protected static $defaultName = 'User';
|
||||
protected static $defaultDescription = '用户';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->addOption('user_id','u', InputArgument::OPTIONAL, 'user_id');
|
||||
$this->addOption('action','a', InputArgument::OPTIONAL, '操作类型');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
* @return int
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$action = $input->getOption('action','login');
|
||||
if($action == 'login'){
|
||||
$IM = new \support\OpenImSdk\Client([
|
||||
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
|
||||
'secret' => 'n1e5a6s6m7', // OpenIM密钥
|
||||
]);
|
||||
$user_id = $input->getOption('user_id');
|
||||
if(!$user_id){
|
||||
return false;
|
||||
}
|
||||
$user = \support\Jwt::direct($user_id);
|
||||
$imToken = $IM->auth->getUserToken(idEncode($user['id']),2);
|
||||
cp('userID:' . $user['id']);
|
||||
cp('nickname:' . $user['nickname']);
|
||||
cp('token:' . $user['token']);
|
||||
cp('imToken:' . $imToken['token']);
|
||||
return 0;
|
||||
}
|
||||
cp('action not exist');
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user