Closed zmdyy0318 closed 3 years ago
改函数方法里,当http回复 "{\"code\":5,\"msg\":\"指定对象不存在\"}" 时,未捕获code值,直接使用json获取name 该函数代码如下 GroupMemberInfo MiraiBot::GetGroupMemberInfo(GID_t gid, QQ_t memberId) {
stringstream api_url; api_url << "/memberInfo?sessionKey=" << sessionKey_ << "&target=" << int64_t(gid) << "&memberId=" << int64_t(memberId); auto res = http_client_.Get(api_url.str().data()); if (!res) throw std::runtime_error("网络错误"); if (res->status != 200) throw std::runtime_error("[mirai-api-http error]: " + res->body); json re_json = json::parse(res->body); GroupMemberInfo result; result.Set(re_json); return result;
}
补充:有值时没有返回code
根据mah的设计,这个时候应该返回非200状态码的…… 不得不做个特殊处理了
改函数方法里,当http回复 "{\"code\":5,\"msg\":\"指定对象不存在\"}" 时,未捕获code值,直接使用json获取name 该函数代码如下 GroupMemberInfo MiraiBot::GetGroupMemberInfo(GID_t gid, QQ_t memberId) {
}