delphi 可以登陆Discuz论坛 可是发帖就提示您的请求来路不正确,该怎么处理
delphi 可以登陆Discuz论坛 可是发帖就提示您的请求来路不正确
用管理账号登陆就可以!~ 换别的账号就提示您的请求来路不正确
头都大了,实在弄不明白了上来问问 ,
try
LoginInfo.Clear;
LoginInfo.Add('username=测试'); //这里用管理账号就可以换别的账号就不行
LoginInfo.Add('password=11');
LoginInfo.Add('cookietime=5000');
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.Referer := 'http://bbs.d1gq.com/bbs/logging.php?action=login&referer=http%3A//bbs.d1gq.com/bbs/index.php';
try
IdHTTP1.Post(LoginUrl, LoginInfo, Response);
except
showmessage('登陆失败');
end;
Memo1.Text := 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;
end;
end;
IdHTTP1.Request.RawHeaders.Add('Cookie: ' + MyCookList);
finally
LoginInfo.Free;
Response.Free;
end;
PostInfo := TStringList.Create;
PostInfo.Add('formhash=3124e426');
PostInfo.Add('subject=sdddddddddddd');
PostInfo.Add('message=dsssssssss');
IdHTTP1.Request.CustomHeaders.Add('Cookie: ' + Copy(MyCookList, 1, length(MyCookList) - 1));
IdHTTP1.Request.CacheControl := 'no-cache';
IdHTTP1.Request.Connection := 'Keep-Alive';
IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TencentTraveler )';
IdHTTP1.Request.Referer := 'http://bbs.d1gq.com/bbs/forumdisplay.php?fid=2';
try
s := IdHTTP1.Post(PostUrl, PostInfo);
except
showmessage('发帖失败');
exit;
end;
Memo2.Text := s;
if Pos('无法提交',s)>0 then Memo1.Lines.add(Ausername + ' ' + '无法提交 ..发贴失败.. ');
if pos('您无权进行当前操作',s)>0 then Memo1.Lines.add(Ausername + ' ' + '对不起,您还未登录,无权在该版块发帖。 ..发贴失败.. ');
if pos('刚才',s)>0 then Memo1.Lines.add(Ausername + ' ' + ' ..发贴成功.. ');
end ;
end;
------解决方案--------------------
论坛站点限制外部提交
------解决方案--------------------
我也遇過相同問題
所有可以input的value 我也有用tstringlist加進去
當然 登錄時取得的cookie也有加入
用google搜了半天site:****.net也沒有解決方案
最後只好用webbrowser
------解决方案--------------------
你指定REFER了没有。
------解决方案--------------------
用管理账号登陆就可以!~ 换别的账号就提示您的请求来路不正确
抱歉 我忘了問 你是用普通帳戶登錄成功 然後不能發帖嗎?
用管理账号登陆就可以!~ 换别的账号就提示您的请求来路不正确
头都大了,实在弄不明白了上来问问 ,
try
LoginInfo.Clear;
LoginInfo.Add('username=测试'); //这里用管理账号就可以换别的账号就不行
LoginInfo.Add('password=11');
LoginInfo.Add('cookietime=5000');
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.Referer := 'http://bbs.d1gq.com/bbs/logging.php?action=login&referer=http%3A//bbs.d1gq.com/bbs/index.php';
try
IdHTTP1.Post(LoginUrl, LoginInfo, Response);
except
showmessage('登陆失败');
end;
Memo1.Text := 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;
end;
end;
IdHTTP1.Request.RawHeaders.Add('Cookie: ' + MyCookList);
finally
LoginInfo.Free;
Response.Free;
end;
PostInfo := TStringList.Create;
PostInfo.Add('formhash=3124e426');
PostInfo.Add('subject=sdddddddddddd');
PostInfo.Add('message=dsssssssss');
IdHTTP1.Request.CustomHeaders.Add('Cookie: ' + Copy(MyCookList, 1, length(MyCookList) - 1));
IdHTTP1.Request.CacheControl := 'no-cache';
IdHTTP1.Request.Connection := 'Keep-Alive';
IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TencentTraveler )';
IdHTTP1.Request.Referer := 'http://bbs.d1gq.com/bbs/forumdisplay.php?fid=2';
try
s := IdHTTP1.Post(PostUrl, PostInfo);
except
showmessage('发帖失败');
exit;
end;
Memo2.Text := s;
if Pos('无法提交',s)>0 then Memo1.Lines.add(Ausername + ' ' + '无法提交 ..发贴失败.. ');
if pos('您无权进行当前操作',s)>0 then Memo1.Lines.add(Ausername + ' ' + '对不起,您还未登录,无权在该版块发帖。 ..发贴失败.. ');
if pos('刚才',s)>0 then Memo1.Lines.add(Ausername + ' ' + ' ..发贴成功.. ');
end ;
end;
------解决方案--------------------
论坛站点限制外部提交
------解决方案--------------------
我也遇過相同問題
所有可以input的value 我也有用tstringlist加進去
當然 登錄時取得的cookie也有加入
用google搜了半天site:****.net也沒有解決方案
最後只好用webbrowser
------解决方案--------------------
你指定REFER了没有。
------解决方案--------------------
用管理账号登陆就可以!~ 换别的账号就提示您的请求来路不正确
抱歉 我忘了問 你是用普通帳戶登錄成功 然後不能發帖嗎?