部分的登录代码
CString TMLogin(CString MyIDPhone,CString MyPass,DeviceInfo MyDeviceInfo)
{
CString MyPassS,MySig,MyUrl,MyVideo,MyPage,strbodyStr,strbody,strbodyLenStr;
try
{
CoInitialize(0);
IWinHttpRequestPtr http=NULL;
http.CreateInstance("WinHttp.WinHttpRequest.5.1");
MyPassS=GetMd5Str(MyPass);
MyPassS=MyPassS.Left(16);
MyPassS.MakeLower();
strbody="{\"phone\":\""+MyIDPhone+"\",\"pw\":\""+MyPassS+"\",\"region_code\":86,\"h_av\":\"4.7.0\",\"h_dt\":0,\"h_os\":19,\"h_app\":\"zyou\",\"h_model\":\"R2010\",\"h_did\":\""+MyDeviceInfo.h_did+"\",\"h_nt\":1,\"h_ch\":\"ppzhushou\",\"h_ts\":"+TMGZSGoble.GetUnixTime()+TMGZSGoble.SJSZ(3)+",\"android_id\":\""+MyDeviceInfo.htoken+"\"}";
strbodyLenStr.Format("%d",strbody.GetLength());
MySig=GetSign(strbody);
MyUrl="http://api.***you.com/account/login?sign="+MySig;
http->Open("POST",(_bstr_t)MyUrl, false);
http->SetRequestHeader("Request-Type","text/json");
http->SetRequestHeader("User-Agent","okhttp/3.11.0 ****ou/4.7.0");
http->SetRequestHeader("Content-Type","application/json; charset=utf-8");
http->SetRequestHeader("Content-Length",(_bstr_t)strbodyLenStr);
http->SetRequestHeader("Connection","Keep-Alive");
http->Send((_bstr_t)strbody);
http-> WaitForResponse();
BSTR TTxets=NULL;
_variant_t vbin=http->get_ResponseText(&TTxets);
CString Tdata=CString((LPCTSTR)(_bstr_t)TTxets);
::SysFreeString(TTxets); // 释放空间
_bstr_t Tdatas=http->GetAllResponseHeaders();
CString TdataTmp= (LPCTSTR)Tdatas;
http.Release();
CoUninitialize();
return Tdata; //-3手机号没注册 -2 账号密码错误
}
catch(...)
{
return "0";
}
}
免责声明
若因使用代码与官方造成不必要的纠纷,本人盖不负责,存粹技术爱好,若侵犯贵公司的权益,请告知!