|
|
@@ -32,7 +32,7 @@ bool CZhipuziHttpClient::Login(std::string& errmsg)
|
|
|
std::map<string, string> params;
|
|
|
|
|
|
std::string response;
|
|
|
- bool ret = m_client.Request("/user/login", params, response);
|
|
|
+ bool ret = m_client.Request("/login/login", params, response);
|
|
|
|
|
|
if (!ret)
|
|
|
{
|
|
|
@@ -73,12 +73,19 @@ bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> param
|
|
|
std::string nonce = "123456";
|
|
|
std::string machinecode = "e6bc5694877b2aec";
|
|
|
|
|
|
+ std::string lwm_appid = "84b19199fd221a78c491cd553cbb4ab7";
|
|
|
+ std::string open_secret = "#repast!@#AfAS#@!";
|
|
|
+
|
|
|
+ std::string upper_passowrd = m_password;
|
|
|
+ transform(upper_passowrd.begin(), upper_passowrd.end(), upper_passowrd.begin(), ::toupper);
|
|
|
+
|
|
|
//先添加默认参数,用于计算签名
|
|
|
+ params["machinecode"] = machinecode;
|
|
|
params["username"] = m_username;
|
|
|
- params["timestamp"] = timestamp;
|
|
|
+ params["password"] = upper_passowrd;
|
|
|
+ params["lwm_appid"] = "84b19199fd221a78c491cd553cbb4ab7";
|
|
|
params["nonce"] = nonce;
|
|
|
- params["machinecode"] = machinecode;
|
|
|
- params["url"] = m_url + url;
|
|
|
+ params["timestamp"] = timestamp;
|
|
|
|
|
|
//计算签名
|
|
|
std::string postString;
|
|
|
@@ -94,21 +101,18 @@ bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> param
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //LOG_INFO("postString:" << postString.c_str());
|
|
|
-
|
|
|
- std::string key = md5(m_password);
|
|
|
- transform(key.begin(), key.end(), key.begin(), ::toupper);
|
|
|
+ LOG_INFO("postString:" << postString.c_str());
|
|
|
|
|
|
//用于计算签名的临时变量
|
|
|
- std::string tmp = postString + key;
|
|
|
+ string tmp = md5(postString);
|
|
|
+ tmp += open_secret;
|
|
|
|
|
|
- string sign = md5(tmp);
|
|
|
+ std::string sign = md5(tmp);
|
|
|
transform(sign.begin(), sign.end(), sign.begin(), ::toupper);
|
|
|
- //LOG_INFO("sign:" << sign.c_str());
|
|
|
+ LOG_INFO("sign:" << sign.c_str());
|
|
|
|
|
|
//加上签名,去掉url,计算post
|
|
|
params["sign"] = sign;
|
|
|
- params.erase("url");
|
|
|
|
|
|
postString = "";
|
|
|
for (std::map<string, string>::iterator it = params.begin(); it != params.end(); )
|
|
|
@@ -123,13 +127,13 @@ bool CZhipuziHttpClient::Request(std::string url, std::map<string, string> param
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //LOG_INFO("postString:" << postString.c_str());
|
|
|
+ LOG_INFO("postString:" << postString.c_str());
|
|
|
|
|
|
int ret = m_httpClient.Posts(m_url + url, postString, response, NULL);
|
|
|
|
|
|
- //LOG_INFO("response:" << response.c_str());
|
|
|
+ LOG_INFO("response:" << response.c_str());
|
|
|
|
|
|
- if (!ret)
|
|
|
+ if (ret == 0)
|
|
|
{
|
|
|
//ret为0表示没有出错
|
|
|
return true;
|