{发送手机短信}
function SendMobileMessage(telNum, msgContent: AnsiString):Boolean;
var
idHTTP: TIdHTTP;
postStream: TStringStream;
content,str: AnsiString;
begin
idHTTP := TIdHTTP.Create(nil);
postStream := TStringStream.Create('', TEncoding.UTF8);
try
try
{账号zkzb=zhongkuang123}
{协议包头定义}
idHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
{定义发送mime类型}
idHTTP.HandleRedirects := True;
{允许重定向,因为这个站点会发生重定向 }
idHTTP.Request.Connection := 'Keep-Alive';
idHTTP.Request.UserAgent := 'Mozilla/4.0 (compatible;
MSIE 6.0;
Windows NT 5.1;
SV1;
.NET CLR 2.0.50727;
.NET CLR 3.0.04506.648;
.NET CLR 3.5.21022)';
content := 'http://api.smsbao.com/sms';
str := '?u=' + ('amwgaii' ) +
'&p=' + ( md5jm.MD5Print( MD5String( 'amwgaii' ) ) )+
'&m=' + ( telNum )+
'&c=' + TNetEncoding.URL.Encode(string( msgContent ) );
str := content + str;
IdHTTP.get(str, postStream);
Result :=True;
except
Result :=False;
end;
finally
idHTTP.Free;
postStream.Free;
end;
end;
推荐阅读
- Pascal基础语法(一)
- Delphi动态创建MainMenu和PopupMenu菜单的方法
- delphi|Delphi编写网络程序的安全措施
- Delphi中WebBrowser判断页面及JS是否加载完成
- delphi idhttpserver ajax 跨域
- Delphi中WebBrowser判断页面及JS ajax是否加载完成-转
- Delphi|APP 多张图片滑动显示 - 之二