Git Product home page Git Product logo

server-sdk-php's Issues

支持设置超时时间

最近发现接口请求有时候略慢
可否加入请求超时重试的选项,或者简单点支持设置超时时间也行

这个SDK写得还不如旧版的

  • 自述
    • 首先,一定要自我批评,避免大家攻击我,认为我自以为是:
      大家好,我是一个渣渣,对一部分人来说,我可能是最讨厌的一类人,自述完毕!
  • 问题描述
    emmmmm。。。我不是针对谁,但是一看就是原来程序员离职了,新人(我们称之为“小白”)接手了,完了,这个小白察觉出旧版的弊端:没有命名空间,然后一顿操作猛如虎,新版SDK上线了。。。喜闻乐见,以下代码在SDK中很常见,不是个例,不要认为我鸡蛋里面挑骨头:
    代码链接
/**
     * 添加封禁
     *
     * @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;
    }

messagePublish方法没有办法群发。。。

/**
 * 发送会话消息
 * @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还要自己改,心累~~

发送消息失败

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);

返回的结果:
image
更改sdk中的send方法添加content-type json,返回结果为:
image
完全无从下手了。
ps.使用curl单独写了调用的接口,发现不管发送的参数是json_encode,数组,http_build_query都不行

代码错误

刚刚升级的版本中有个错误,Request类177行,in_array方法使用错误。参数传反了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.