C# 如何登录Wordpress管理仪表板?
我正在尝试使用C#登录Wordpress管理仪表板 代码很简单,可以在每个网站上运行,甚至在谷歌上(当然参数不同)。C# 如何登录Wordpress管理仪表板?,c#,.net,wordpress,cookies,C#,.net,Wordpress,Cookies,我正在尝试使用C#登录Wordpress管理仪表板 代码很简单,可以在每个网站上运行,甚至在谷歌上(当然参数不同)。 发送帖子后,我又进入了登录页面…嗯,经过6个小时的思考,我编写了运行正常的代码(我可以通过WebClient下载管理仪表板页面(支持cookies))。它通过SSL连接,创建CookieContainer并将其放入WebClient(“我的代码中的WebHelper”) 代码如下:经过6个小时的思考,我编写了有效的代码(我可以通过WebClient(支持cookies)下载管理仪
发送帖子后,我又进入了登录页面…嗯,经过6个小时的思考,我编写了运行正常的代码(我可以通过WebClient下载管理仪表板页面(支持cookies))。它通过SSL连接,创建CookieContainer并将其放入WebClient(“我的代码中的WebHelper”)
代码如下:经过6个小时的思考,我编写了有效的代码(我可以通过WebClient(支持cookies)下载管理仪表板页面)。它通过SSL连接,创建CookieContainer并将其放入WebClient(“我的代码中的WebHelper”) 代码如下:
public bool LogIn()
{
// webHelper is WebClient with cookies support (I can login on other sites with this class, even on Google)
string siteHtmlSource = webHelper.DownloadStuff(PageUrl + "/wp-login.php");
siteHtmlSource = webHelper.UploadStuff(PageUrl + "/wp-login.php",
"log=" + HttpUtility.UrlEncode(UserName) + "&pwd=" + HttpUtility.UrlEncode(PassWord) +
"&rememberme=forever&wp-submit=Log+In&redirect_to=" + HttpUtility.UrlEncode(PageUrl) +
"%2Fwp-admin%2F&testcookie=1");
if (!siteHtmlSource.Contains("Dashboard"))
{
loggedIn = false;
return false;
}
loggedIn = true;
return true;
}