rongcloud / server-sdk-php Goto Github PK
View Code? Open in Web Editor NEWRongCloud Server SDK in PHP.
License: MIT License
RongCloud Server SDK in PHP.
License: MIT License
规范问题: Message类的PublishSystem方法首字母应该小写,
最近发现接口请求有时候略慢
可否加入请求超时重试的选项,或者简单点支持设置超时时间也行
/**
* 添加封禁
*
* @param array $Chatroom
* $Chatroom = [
];
* @return mixed|null
*/
public function getList(array $Chatroom=[]){
$conf = $this->conf['getList'];
$result = (new Request())->Request($conf['url'],$Chatroom);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
if($result['code'] == 200){
$result = (new Utils())->rename($result,['users'=>'members']);
foreach ($result['members'] as $k=>&$v){
$v = (new Utils())->rename($v,['userId'=>'id']);
}
}
return $result;
}
你们更新代码的时候,能不能把composer 的仓库也更新下,都什么版本了,还不使用标准的composer来管理
/**
* 发送会话消息
* @param $fromUserId 发送人用户 Id。(必传)
* @param $toUserId 接收用户 Id,提供多个本参数可以实现向多人发送消息。(必传)
* @param $objectName 消息类型,参考融云消息类型表.消息标志;可自定义消息类型。(必传)
* @param $content 发送消息内容,参考融云消息类型表.示例说明;如果 objectName 为自定义消息类型,该参数可自定义格式。(必传)
* @param string $pushContent 如果为自定义消息,定义显示的 Push 内容。(可选)
* @param string $pushData 针对 iOS 平台,Push 通知附加的 payload 字段,字段名为 appData。(可选)
* @return json|xml
*/
public function messagePublish($fromUserId, $toUserId = array(), $objectName, $content, $pushContent='', $pushData = '') {
try{
if(empty($fromUserId))
throw new Exception('发送人用户 Id 不能为空');
if(empty($toUserId))
throw new Exception('接收用户 Id 不能为空');
if(empty($objectName))
throw new Exception('消息类型 不能为空');
if(empty($content))
throw new Exception('发送消息内容 不能为空');
$params = array(
'fromUserId'=>$fromUserId,
'objectName'=>$objectName,
'content'=>$content,
'pushContent'=>$pushContent,
'pushData'=>$pushData,
'toUserId' => $toUserId
);
$ret = $this->curl('/message/publish', $params);
if(empty($ret))
throw new Exception('请求失败');
return $ret;
}catch (Exception $e) {
print_r($e->getMessage());
}
}
仔细看了代码就只能发一个用户,备注却写着可以群发。。。。为啥要同一个参数名 多个这样sdk还要自己改,心累~~
我使用的是laradock环境,最近也一直在上面开发,环境没有问题
https://github.com/laradock/laradock
但是我参数调用正确情况给我返回7.
然后,我用本地hombrew环境搭建的同样版本的环境,同样的参数去调用你们的SDK,返回给我的是json
例如:chatroomCreate
直接引入php文件是很原始的方式了,现在都是各种php框架,依赖composer,建议封装为composer组件包
php代码
$RongSDK = new RongCloud('xxx', 'xxx');
$rr = $RongSDK->_message->Person()->send([
'senderId'=> 'ujadk90ha',//发送人 id
'targetId'=> 'markoiwm',//接收人 id
"objectName"=>'RC:TxtMsg',//消息类型 文本
'content'=>['content'=>'你好,小明']//消息体
]);
Utils::dump("发送消息", $rr);
返回的结果:
更改sdk中的send方法添加content-type json,返回结果为:
完全无从下手了。
ps.使用curl单独写了调用的接口,发现不管发送的参数是json_encode,数组,http_build_query都不行
3.0没有找到获取token的例子。
user->register()就是获取token吗?
希望能够将sdk同步到Packagist
建议使用命名空间, 特别是User类, 很容易和现有系统的User类冲突, 另外建议做成composer的扩展, 没有命名空间的类很容易和现在的系统冲突, 我都是手动给每个类加上了命名空间
刚刚升级的版本中有个错误,Request类177行,in_array方法使用错误。参数传反了。
如题,希望可以把那个项目也更新到3.0,这样可以用composer进行安装
[8]Undefined index: minute 错误
Message的publishPrivate,publishSystem,publishGroup等等方法的最后两个参数没有写默认值, 不符合规范, 方法注释中没有指定变量类型
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.