使用Indy9+D7实现CSDN论坛的登录,回复,发贴,发短信功能
来源:互联网 发布:docker overlay centos 编辑:程序博客网 时间:2024/05/02 17:19
使用Indy9+D7实现CSDN论坛的登录,回复,发贴,发短信功能
代码片断:
const
LoginUrl='http://www.csdn.net/member/logon.asp';
PostUrl='http://community.csdn.net/Expert/PostNew_SQL.asp';
ReplyUrl='http://community.csdn.net/Expert/reply.asp';
MsgUrl='http://community.csdn.net/message_board/postsend.asp';
MyCookList:全局变量,取得当前用户的Cookie
IdHTTP1: TIdHTTP;
登录:
function Logon(UserName, PassWord, CookieTime: string):boolean;
var
LoginInfo: TStrings;
Response: TStringStream;
i: Integer;
Cookie:string;
begin
Result :=False;
Cookie:='';
MyCookList :='';
Response := TStringStream.Create('');
LoginInfo := TStringList.Create;
try
LoginInfo.Clear;
LoginInfo.Add('login_name='+UserName);
LoginInfo.Add('password='+PassWord);
LoginInfo.Add('from=http://community.csdn.net/Expert/Forum.asp');
LoginInfo.Add('cookietime='+CookieTime);
LoginInfo.Add('x=0');
LoginInfo.Add('y=0');
IdHTTP1.Request.Referer:='http://www.csdn.net/member/logon.asp';
IdHTTP1.Request.From :='http://community.csdn.net/Expert/Forum.asp';
try
IdHTTP1.Post(LoginUrl,LoginInfo,Response);
except
showmessage('登陆失败');
end;
showmessage(Response.DataString);
//从返回的页面中找出cookie
for i :=0 to IdHTTP1.Response.RawHeaders.Count-1 do
begin
if UpperCase(Copy(IdHTTP1.Response.RawHeaders[i],1,10)) = 'SET-COOKIE' then
begin
Cookie :=Trim(Copy(IdHTTP1.Response.RawHeaders[i],12,MAXINT));
Cookie :=Copy(Cookie,1,Pos(';',Cookie));
MyCookList :=MyCookList+Cookie;
// showmessage(Cookie);
end;
end;
IdHTTP1.Request.RawHeaders.Add('Cookie: '+MyCookList);
finally
LoginInfo.Free;
Response.Free;
end;
if length(MyCookList)>200 then
result:=True;
end;
//回复
function Reply(TopicID, Content: string): boolean;
var
ReplyInfo: TStrings;
Response: TStringStream;
begin
Result :=False;
ReplyInfo := TStringList.Create;
Response :=TStringStream.Create('');
try
begin
//取回复页面
ReplyInfo.Clear;
ReplyInfo.Add('Topicid='+TopicID);
ReplyInfo.Add('xmlReply=aaaaa');
ReplyInfo.Add('csdnname=');
ReplyInfo.Add('csdnpassword=');
ReplyInfo.Add('ReplyContent='+Content);
IdHTTP1.Request.CustomHeaders.Add('Cookie: '+copy(MyCookList,1,length(MyCookList)-1));
IdHTTP1.Request.Referer :='http://community.csdn.net/Expert/xsl/Reply_Xml.asp Topicid='+TopicID;
IdHTTP1.Request.UserAgent:='Redhat/9.0';
try
IdHTTP1.Post(ReplyUrl,ReplyInfo,Response);
except
showmessage('回复失败');
exit;
end;
// showmessage(Response.DataString);
if pos('添加完成,正在生成静态页面,请稍候',Response.DataString)>0 then
Result :=true;
end;
finally
ReplyInfo.Free;
Response.Free;
end;
end;
//发贴
function PostNew(RoomID, Point, TopicName,
Content: string): boolean;
var
PostInfo: TStrings;
Response: TStringStream;
begin
Result :=False;
PostInfo := TStringList.Create;
Response :=TStringStream.Create('');
try
begin
//取发贴页面
//typestate=1&Point=20&TopicName=test&Room=1404&Content=111222
PostInfo.Clear;
PostInfo.Add('typestate=1');
PostInfo.Add('Point='+Point);
PostInfo.Add('TopicName='+TopicName);
PostInfo.Add('Room='+RoomID);
PostInfo.Add('Content='+Content);
IdHTTP1.Request.CustomHeaders.Add('Cookie: '+copy(MyCookList,1,length(MyCookList)-1));
IdHTTP1.Request.CacheControl:='no-cache';
IdHTTP1.Request.UserAgent:='Windows Advanced Server/5.0';
try
IdHTTP1.Post(PostUrl,PostInfo,Response);
except
showmessage('发帖失败');
exit;
end;
// showmessage(Response.DataString);
if pos('增加成功,请稍候,正在生成静态页面',Response.DataString)>0 then
Result :=true;
end;
finally
PostInfo.Free;
Response.Free;
end;
end;
//发短信
function SendMsg(SendTo, Content: string): boolean;
var
PostInfo: TStrings;
Response: TStringStream;
begin
Result :=False;
PostInfo := TStringList.Create;
Response :=TStringStream.Create('');
try
begin
PostInfo.Clear;
PostInfo.Add('Sendto='+SendTo);
PostInfo.Add('Content='+Content);
IdHTTP1.Request.CustomHeaders.Add('Cookie: '+copy(MyCookList,1,length(MyCookList)-1));
try
IdHTTP1.Post(MsgUrl,PostInfo,Response);
except
showmessage('发送失败');
exit;
end;
// showmessage(Response.DataString);
if pos('发送成功',Response.DataString)>0 then
Result :=true;
end;
finally
PostInfo.Free;
Response.Free;
end;
end;
const
LoginUrl='http://www.csdn.net/member/logon.asp';
PostUrl='http://community.csdn.net/Expert/PostNew_SQL.asp';
ReplyUrl='http://community.csdn.net/Expert/reply.asp';
MsgUrl='http://community.csdn.net/message_board/postsend.asp';
MyCookList:全局变量,取得当前用户的Cookie
IdHTTP1: TIdHTTP;
登录:
function Logon(UserName, PassWord, CookieTime: string):boolean;
var
LoginInfo: TStrings;
Response: TStringStream;
i: Integer;
Cookie:string;
begin
Result :=False;
Cookie:='';
MyCookList :='';
Response := TStringStream.Create('');
LoginInfo := TStringList.Create;
try
LoginInfo.Clear;
LoginInfo.Add('login_name='+UserName);
LoginInfo.Add('password='+PassWord);
LoginInfo.Add('from=http://community.csdn.net/Expert/Forum.asp');
LoginInfo.Add('cookietime='+CookieTime);
LoginInfo.Add('x=0');
LoginInfo.Add('y=0');
IdHTTP1.Request.Referer:='http://www.csdn.net/member/logon.asp';
IdHTTP1.Request.From :='http://community.csdn.net/Expert/Forum.asp';
try
IdHTTP1.Post(LoginUrl,LoginInfo,Response);
except
showmessage('登陆失败');
end;
showmessage(Response.DataString);
//从返回的页面中找出cookie
for i :=0 to IdHTTP1.Response.RawHeaders.Count-1 do
begin
if UpperCase(Copy(IdHTTP1.Response.RawHeaders[i],1,10)) = 'SET-COOKIE' then
begin
Cookie :=Trim(Copy(IdHTTP1.Response.RawHeaders[i],12,MAXINT));
Cookie :=Copy(Cookie,1,Pos(';',Cookie));
MyCookList :=MyCookList+Cookie;
// showmessage(Cookie);
end;
end;
IdHTTP1.Request.RawHeaders.Add('Cookie: '+MyCookList);
finally
LoginInfo.Free;
Response.Free;
end;
if length(MyCookList)>200 then
result:=True;
end;
//回复
function Reply(TopicID, Content: string): boolean;
var
ReplyInfo: TStrings;
Response: TStringStream;
begin
Result :=False;
ReplyInfo := TStringList.Create;
Response :=TStringStream.Create('');
try
begin
//取回复页面
ReplyInfo.Clear;
ReplyInfo.Add('Topicid='+TopicID);
ReplyInfo.Add('xmlReply=aaaaa');
ReplyInfo.Add('csdnname=');
ReplyInfo.Add('csdnpassword=');
ReplyInfo.Add('ReplyContent='+Content);
IdHTTP1.Request.CustomHeaders.Add('Cookie: '+copy(MyCookList,1,length(MyCookList)-1));
IdHTTP1.Request.Referer :='http://community.csdn.net/Expert/xsl/Reply_Xml.asp Topicid='+TopicID;
IdHTTP1.Request.UserAgent:='Redhat/9.0';
try
IdHTTP1.Post(ReplyUrl,ReplyInfo,Response);
except
showmessage('回复失败');
exit;
end;
// showmessage(Response.DataString);
if pos('添加完成,正在生成静态页面,请稍候',Response.DataString)>0 then
Result :=true;
end;
finally
ReplyInfo.Free;
Response.Free;
end;
end;
//发贴
function PostNew(RoomID, Point, TopicName,
Content: string): boolean;
var
PostInfo: TStrings;
Response: TStringStream;
begin
Result :=False;
PostInfo := TStringList.Create;
Response :=TStringStream.Create('');
try
begin
//取发贴页面
//typestate=1&Point=20&TopicName=test&Room=1404&Content=111222
PostInfo.Clear;
PostInfo.Add('typestate=1');
PostInfo.Add('Point='+Point);
PostInfo.Add('TopicName='+TopicName);
PostInfo.Add('Room='+RoomID);
PostInfo.Add('Content='+Content);
IdHTTP1.Request.CustomHeaders.Add('Cookie: '+copy(MyCookList,1,length(MyCookList)-1));
IdHTTP1.Request.CacheControl:='no-cache';
IdHTTP1.Request.UserAgent:='Windows Advanced Server/5.0';
try
IdHTTP1.Post(PostUrl,PostInfo,Response);
except
showmessage('发帖失败');
exit;
end;
// showmessage(Response.DataString);
if pos('增加成功,请稍候,正在生成静态页面',Response.DataString)>0 then
Result :=true;
end;
finally
PostInfo.Free;
Response.Free;
end;
end;
//发短信
function SendMsg(SendTo, Content: string): boolean;
var
PostInfo: TStrings;
Response: TStringStream;
begin
Result :=False;
PostInfo := TStringList.Create;
Response :=TStringStream.Create('');
try
begin
PostInfo.Clear;
PostInfo.Add('Sendto='+SendTo);
PostInfo.Add('Content='+Content);
IdHTTP1.Request.CustomHeaders.Add('Cookie: '+copy(MyCookList,1,length(MyCookList)-1));
try
IdHTTP1.Post(MsgUrl,PostInfo,Response);
except
showmessage('发送失败');
exit;
end;
// showmessage(Response.DataString);
if pos('发送成功',Response.DataString)>0 then
Result :=true;
end;
finally
PostInfo.Free;
Response.Free;
end;
end;
- 使用Indy9+D7实现CSDN论坛的登录,回复,发贴,发短信功能
- 使用Indy9+D7实现CSDN论坛的登录,回复,发贴,发短信功能
- 使用Indy9+D7实现CSDN论坛的登录,回复,发贴,发短信
- CSDN的论坛在除夕之夜不能发贴回复了?
- 基于java实现发短信的功能
- 发短信功能代码实现
- Android 发短信功能实现
- Java实现发短信功能
- CSDN 论坛发广告?
- 实现两个模拟器之间发短信的功能
- andorid下实现定时发短信的功能
- andorid下实现定时发短信的功能
- andorid下实现定时发短信的功能
- ios中发短信功能实现的几种方式
- iOS 打电话 发短信功能的简单实现
- iOS 调用系统发短信功能的实现
- Oc 拨打电话和发短信功能的实现
- webapp开发之打电话、发短信、发邮件功能实现
- 如何部署Creator2开发的应用到单独下载安装的sun appserver pe8上!
- at&a语法和intel语法
- 上手篇-在eclipse中开发第一个openlaslzo的RIA
- 关于JSF应用程序生命周期与Creator2阶段方法的深入研究
- creator2中新增数据库记录的table法
- 使用Indy9+D7实现CSDN论坛的登录,回复,发贴,发短信功能
- Creator2中关于文件上传组件的使用
- Creator2中关于组件验证的几种方式
- JSF框架实现各种类型文件的上传下载
- Creator中关于列表框的使用
- JBPM的一些介绍
- GridView控件修改、删除示例(修改含有DropDownList控件)
- 用存储过程或触发器+作业调度进行数据库同步
- InfoPath开发经验小节