1. Go to this page and download the library: Download awang/weapp-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use \QCloud_WeApp_SDK\Tunnel\TunnelService;
use \QCloud_WeApp_SDK\Tunnel\ITunnelHandler;
class TunnelHandler implements ITunnelHandler {
// TODO: 传入登录的用户信息
public function __construct($userinfo) {
}
// TODO: 实现 onRequest 方法,处理信道连接请求
public function onRequest($tunnelId, $tunnelUrl) {
}
// TODO: 实现 onConnect 方法,处理信道连接事件
public function onConnect($tunnelId) {
}
// TODO: 实现 onMessage 方法,处理信道消息
public function onMessage($tunnelId, $type, $content) {
}
// TODO: 实现 onClose 方法,处理信道关闭事件
public function onClose($tunnelId) {
}
}
$handler = new TunnelHandler();
TunnelService::handle($handler, array('checkLogin' => TRUE));