flutter 即时通讯服务号

服务号一般是在服务端发送消息,Flutter SDK 主要用于客户端。

创建服务号时能成功,但是订阅服务号的时候,返回错误如下:

{"code":1,"error":"This request must be signed by master key."}

请求头的设置和创建服务号一样,都带上了master key

function subscribeService($clientID){
    $headers=array();
    $headers[]='X-LC-Id: OocEy1draipXLCeRz9hMPWA9-9Nh9j0Va';
    $headers[]='X-LC-Key: masterkey';
    $headers[]='Content-Type: application/json';

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'https://我的域名/1.2/rtm/service-conversations/服务号的ObjectId/subscribers');
    curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
    $data = json_encode(array('client_id'=>$clientID));
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    $res = curl_exec($curl);
    curl_close($curl);
    return $res;
}

这是咋回事?

你好,如果您使用的是 MasterKey,需要在值的结尾加上 ,master

另外任何拥有了 MasterKey 的人都可以绕过应用的所有权限设置对应用数据进行操作,所以要注意不要将 MasterKey 公开出来。建议您立即前往 控制台 > 设置 > 应用凭证 重置 MasterKey。

是不是您用的 flutter SDK 版本比较旧?(全文搜索功能是后来新加的)
建议升级 SDK 到当前最新版再试试。