You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
declare(strict_types=1);namespace App\Controller;
use App\Libs\FeiePrintClient;use Hyperf\HttpServer\Contract\RequestInterface;use Hyperf\HttpServer\Annotation\AutoController;use Hyperf\Utils\Coroutine;use Hyperf\Utils\ApplicationContext;use Hyperf\Task\TaskExecutor;use Hyperf\Task\Task;use App\TaskWorker\SSDBTask;use App\Commons\Log;
/** * @AutoController() * Class TestController * @package App\Controller */class TestController extends AbstractController{ private $name = 'default action';
protected $client = null;
public function index1(RequestInterface $request) { // $container = ApplicationContext::getContainer();
// $exec = $container->get(TaskExecutor::class);
// $result = $exec->execute(new Task([MethodTask::class, 'handle'], [Coroutine::id()]));
// $client = ApplicationContext::getContainer()->get(SSDBTask::class);
// $result = $client->exec("set","bar","1234");
// $result = $client->exec("get","bar");
// $client = ApplicationContext::getContainer()->get(MethodTask::class);
// $result = $client->handle("set");
// //$log = ApplicationContext::getContainer()->get(Log::class);
// $log = $this->log;
//
// $log->push(['test'=>1,'user_id'=>290,'msg'=>'order']);
// $log->event('t1',['test'=>1,'user_id'=>290,'msg'=>'order']);
//
// //$this->name = 'index1 action '. $result;
// return $this->name;
$time = time(); $msgInfo = array( 'user' => '13161443713@163.com', 'stime' => $time, 'sig' => sha1('13161443713@163.com' . 'XsaHzgePdyWTfcMX' . $time), 'apiname' => 'Open_printMsg', 'sn' => '920527381', 'content' => '1111', 'times' => 1//打印次数
); $this->client = new FeiePrintClient('api.feieyun.cn', 80); if (!$this->client->post('/Api/Open/', $msgInfo)) { return '12'; } else { //服务器返回的JSON字符串,建议要当做日志记录起来
$result = $this->client->getContent(); return $result; } }
public function index2(RequestInterface $request) { $this->name = 'index2 action'; return $this->name; }
public function index3(RequestInterface $request) { return $this->name; }}
|