idhttp控件的post编码问题

wshzhi 2010-06-07 09:40:33
最近在做一个发贴工具,用的是delphi2010 indy10 ,论坛是discuz big5码,登陆没问题,但是发贴时,贴子内容是乱码。
发贴函数如下:

Function TForm1.postinfo(url, subject, wsmessage,fid: string): Boolean;
var
Param:TStringList;
geturl:String;
Response:TStringStream;
begin
Result:=False;
geturl:=url+'/index.php';
//

idhttp1.AllowCookies:=True;
idhttp1.HandleRedirects:=True;
//idhttp1.Request.Accept:='image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*';
idhttp1.Request.Referer:=url+'/post.php?action=newthread&fid='+fid;
IdHTTP1.HTTPOptions:=IdHTTP1.HTTPOptions+[hoKeepOrigProtocol];
idhttp1.Request.AcceptLanguage:='zh-cn';
idhttp1.Request.ContentType:='application/x-www-form-urlencoded' ;
idhttp1.Request.AcceptEncoding :='gzip, deflate';
idhttp1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 2.0.50727)';
idhttp1.Request.Connection:='keep-alive';

idhttp1.Request.CacheControl:='no-cache';


Param:=TStringList.Create;
Response:=TStringStream.Create('');
try
wsmessage:=ansitoutf8(wsmessage);
param.Clear;
Param.Add('formhash='+formhash);
param.Add('wysiwyg=0');
Param.Add('subject='+subject);
Param.Add('message='+wsmessage);
param.Add('iconid=');
param.Add('addfeed=1');
param.Add('topicsubmit=%B5o%B7s%B8%DC%C3D');
//Param.Add('userlogin=%E7%99%BB%E5%BD%95');
url:=url+'/post.php?action=newthread&fid='+fid+'&extra=&topicsubmit=yes';
try
idhttp1.Post(url,param,response);

except
showmessage('发贴失败');
end;
finally
Param.Free;
response.Free;
end;
showmessage(response.DataString);

end;
...全文
289 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
ifengshow 2010-06-08
  • 打赏
  • 举报
回复
呵呵,我也做了一个,不过我的更简单,就只Post数据
wshzhi 2010-06-08
  • 打赏
  • 举报
回复
没有回复的?delphi版的人家这么不旺吗?
wshzhi 2010-06-08
  • 打赏
  • 举报
回复
一定要用idhttp,webbrowser的我做出来了。
wshzhi 2010-06-08
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 sinopf 的回复:]

用支持unicode的D2010试试用UTF-8编码
[/Quote]
我就是用的d2010
sinopf 2010-06-08
  • 打赏
  • 举报
回复
用支持unicode的D2010试试用UTF-8编码
wshzhi 2010-06-08
  • 打赏
  • 举报
回复
这么快就下来,我自己顶,难道真没知道的?
wshzhi 2010-06-08
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 tjianliang 的回复:]

你提交的发帖内容是什么编码
[/Quote]
是汉字,发英文没问题,发汉字,gb2312,就有问题,在简体winxp下.
ilovesafety 2010-06-08
  • 打赏
  • 举报
回复
难道楼主在制作传说中的发贴机
亮剑_ 2010-06-07
  • 打赏
  • 举报
回复
你提交的发帖内容是什么编码
wshzhi 2010-06-07
  • 打赏
  • 举报
回复
没有知道的吗?我GG了一天了,也没找出解决方案
xjwy 2010-06-07
  • 打赏
  • 举报
回复
沙发,我坐,呵呵,帮你顶

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧