是不是gatewayclient沒有安裝對還是怎么回事,這些接口都不能正常使用,這是怎么回事
header("content-type:text/html;charset=utf-8");
require_once 'GatewayClient/Gateway.php';
use GatewayClient\Gateway;
Gateway::$registerAddress = '127.0.0.1:1236';
$uid = $_POST['user_id'];
//$msg = $_POST['msg'];
$msg = '{"type":"say_to_one","to_client_id":100,"content":"hello"}';
$req_data = json_decode($msg, true);
Gateway::sendToUid($uid, $req_data);
$data['uid'] = $uid;
$data['code'] = 100;
echo json_encode($data);
1、不好使的話就先研究官方的注意事項: https://github.com/walkor/gatewayclient
2、另 void Gateway::sendToUid(mixed $uid, string $message); 第二個參數(shù)要求是string
第二個參數(shù)應該是字符串,你發(fā)的是數(shù)組。
還有$data
也未定義。
另外sendToUid要求有調用bindUid,并且uid在線,否則肯定收不到。
最好用sendToAll接口試下,避免你binduid有問題。