推荐一个我自己做的一个电影站,绝对没弹窗:-) www.fastdy.com 速看电影吧,每天都更新,
最新的电影电视剧都在速看电影吧!~
项目中,因为后台发出的数据格式为JOSN格式,并且为HTTPS, BASE64CODE加密模式,如果前台按照语句长短,标点符号位置,关键词位置来判断,没有一个可以利用的函数是非常废时间,所幸,从万一的BLOG里找到了解决办法
附上DELPHI解决HTTPS协议的连接(其实没有用D加上zhengshu,而是用忽略的方式强行连接)
USE
superobject
function SearChMember(vcarid, vphone, vmemberway: string; var vresult: string; var vtabledata: Variant; var vdifftime: string): Variant; stdcall; var sUrl: string; vs: AnsiString; jo: ISuperObject; ja: TSuperArray; i: Integer; imax, s: Integer; vmsg: string; CDS1: TClientDataSet; Istart: TDateTime; iend: TDateTime; begin try try Istart := Now; CDS1 := TClientDataSet.Create(nil); with CDS1 do begin FieldDefs.Clear; FieldDefs.Add('select', ftBoolean); FieldDefs.Add('c', ftString, 30); FieldDefs.Add('g', ftString, 5); FieldDefs.Add('ch', ftString, 5); FieldDefs.Add('b', ftString, 10); FieldDefs.Add('n', ftString, 50); FieldDefs.Add('p', ftString, 20); FieldDefs.Add('point', ftString, 30); FieldDefs.Add('isgoodbabycard', ftString, 10); FieldDefs.Add('cid', ftString, 30); // 客户编号 FieldDefs.Add('gid', ftString, 10); //等级编号 FieldDefs.Add('cna', ftString, 30); //渠道 CreateDataSet; end; vtabledata := CDS1.Data; Result := CDS1.Data;
if (Length(vphone) > 0) then begin if (Length(vphone) < 11) or (Length(vphone) > 13) then begin Application.MessageBox('请输入正确的手机号!', '提示', MB_OK + MB_ICONINFORMATION); vresult := 'noacess'; Exit; end; end;
if Trim(vcarid) + Trim(vphone) = '' then begin Application.MessageBox('手机号和会员卡号必须填入一个!', '提示', MB_OK + MB_ICONINFORMATION); vresult := 'noacess'; Exit; end; vs := '{' + #34 + 'c' + #34 + ':' + #34 + vcarid + #34 + ',' + #34 + 'p' + #34 + ':' + #34 + vphone + #34 + ',' + #34 + 'ch' + #34 + ':' + #34 + vmemberway + #34 + '}';
if xmlhttpSend(shoppinfo.vwebaddr + 'check.action', vs) = False then exit; jo := SO(vs); vmsg := jo['msg'].AsString; if jo['code'].AsString = '0' then begin vresult := 'no'; Result := null; Exit; end else begin CDS1.EmptyDataSet; CDS1.Active := true; ja := jo['memlist'].AsArray; imax := ja.Length; for i := 0 to imax - 1 do begin CDS1.Append; CDS1.FieldByName('select').AsBoolean := False; CDS1.FieldByName('c').AsString := ja[i]['c'].AsString; CDS1.FieldByName('g').AsString := ja[i]['g'].AsString; CDS1.FieldByName('ch').AsString := ja[i]['ch'].AsString; CDS1.FieldByName('b').AsString := ja[i]['b'].AsString; CDS1.FieldByName('n').AsString := ja[i]['n'].AsString; CDS1.FieldByName('p').AsString := ja[i]['p'].AsString; CDS1.FieldByName('point').AsString := ja[i]['point'].AsString; CDS1.FieldByName('cid').AsString := ja[i]['cid'].AsString; CDS1.FieldByName('isgoodbabycard').AsString := 'Y'; CDS1.FieldByName('gid').AsString := ja[i]['gid'].AsString; CDS1.FieldByName('cna').AsString := ja[i]['cna'].AsString; CDS1.Post; end; if imax = 1 then begin vresult := 'one'; Result := CDS1.Data; vtabledata := CDS1.Data; end else if imax = 0 then begin vresult := 'no'; end else begin vresult := 'many'; Result := CDS1.Data; vtabledata := CDS1.Data; end end;
except Application.MessageBox(PChar('查询会员信息失败,请稍后再试'), '提示', MB_OK + MB_ICONINFORMATION) end; iend := Now; vdifftime := FormatdateTime('hh-mm-ss', iend - istart); if vdifftime = '' then vdifftime := '0' else begin if BackUseTime(shoppinfo.vshoppid, 'check', vdifftime) = '1' then begin
end; end; finally CDS1.Free; end; end;
function xmlhttpSend(vurl: string; var vSource: AnsiString): Boolean; var xmlHttp: Olevariant; vParam: OleVariant; responseText: string; idbsEn: TIdBase64Encoder; idbsDe: TIdBase64Decoder; tempstr: string; begin try
idbsEn := TIdBase64Encoder.Create(nil); idbsDe := TIdBase64Decoder.Create(nil); idbsEn.CodeString(vSource); tempstr := idbsEn.CompletedInput; fetch(tempstr, ';'); vParam := 'param_value=' + tempstr;
xmlHttp := CreateOleObject('MSXML2.ServerXMLHTTP');
//同步执行
xmlHttp.open('POST', vURL, false);
xmlHttp.setRequestHeader('Cache-Control', 'no-cache');
xmlHttp.setRequestHeader('Connection', 'Keep-Alive');
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
xmlHttp.setRequestHeader('User-Agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)');
xmlHttp.setRequestHeader('ContentEncoding', 'GBK');
xmlHttp.setRequestHeader('Content-Length', Length(vParam));
xmlHttp.setRequestHeader('If-Modified-Since', '0');
//忽略SSL的选择请求
xmlHttp.setOption(2, 13056);
xmlHttp.send(vParam); responseText := xmlHttp.responseText; if xmlHttp.status = '200' then begin
idbsDe.CodeString(responseText); tempstr := idbsDe.CompletedInput;
Fetch(tempstr, ';'); vSource := Fetch(tempstr, #0, false); result := True; end else begin result := false; end; finally idbsEn.free; idbsDe.free; end; end;
|
请发表评论