麻烦使用WP远程登录请求进行身份验证

时间:2012-12-27 05:31:01

标签: vb.net wordpress login-control

好的,所以我打算在最后的3个错误上发布这个,但我修复了所有这些(谢天谢地)。我不再获取任何类型的cookie阻止消息,但是现在我收到错误登录是否输入了正确的密码或无效的密码。我想也是 A. cookie存储错误。 B.或重定向问题。

Imports System.Text
Imports System.Net
Imports System.IO

Public Class Form1

Dim logincookie As CookieContainer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)         Handles Button1.Click
    Dim postData As String = "log=" & TextBox1.Text & "&pwd=" & TextBox2.Text & "wp-  submit=Log+In&redirect_to=""http://csvlife.com/wp-admin/" & "&wordpress_test_cookie=1"
    Dim tempcookies As New CookieContainer()
    Dim encoding As New UTF8Encoding
    Dim byteData As Byte() = encoding.GetBytes(postData)
    Dim postreq As HttpWebRequest = DirectCast(HttpWebRequest.Create("http://csvlife.com/wp-login.php"), HttpWebRequest)
    postreq.Method = "POST"
    postreq.KeepAlive = True
    postreq.AllowAutoRedirect = True
    postreq.CookieContainer = tempcookies
    postreq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b6pre) Gecko/20100903 Firefox/4.0b6pre"
    postreq.ContentType = "application/x-www-form-urlencoded"
    postreq.Referer = "http://csvlife.com/wp-login.php"
    postreq.ContentLength = byteData.Length
    Dim postreqstream As Stream = postreq.GetRequestStream()
    postreqstream.Write(byteData, 0, byteData.Length)
    postreqstream.Close()
    Dim postresponse As HttpWebResponse
    postresponse = DirectCast(postreq.GetResponse, HttpWebResponse)
    tempcookies.Add(postresponse.Cookies)
    logincookie = tempcookies
    Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
    Dim thepage As String = postreqreader.ReadToEnd
    If thepage.Contains("ERROR") Then
        MsgBox("Error logging in!")
    Else
        MsgBox("Lets Start Blogging!")
    End If
End Sub
End Class



我打开了我的小提琴手,我已登录页面,注意到我经常通过常规浏览器登录时 提琴手会表明:

enter image description here

然后结果进来,它看起来像这样:

enter image description here

澄清:上面的图片是我从计算机上的任何基本浏览器登录时网络流量信息的样子

以下是我从该程序登录的内容: enter image description here

总是一个错误。 enter image description here

请求编号在之前或之后仅为200无302。

然而,当我尝试通过我的程序时,请求号始终为200,即发布。它就像它永远不会重定向,我不知道为什么。注意:这是我的网站,不适用于任何恶意软件或其他任何类型的恶意软件。它只适用于博客自动化。如果还有什么我可以在这件事上找到,我会的。此时我别无选择。谢谢你的帮助和考虑。

1 个答案:

答案 0 :(得分:1)

第9行:

Dim postData As String =“log =”& TextBox1.Text& “& pwd =”& TextBox2.Text& “wp- submit = Log + In& redirect_to =”“http://csvlife.com/wp-admin/”& “&安培; wordpress_test_cookie = 1”

要与帖子一起发送的参数需要用&符号分隔,因为写入的密码参数附加了“wp- submit = Log + In& redirect_to = http://csvlife.com/wp-admin/”它。

假设wp是一个参数: Dim postData As String =“log =”& TextBox1.Text& “& pwd =”& TextBox2.Text& “& wp- submit = Log + In& redirect_to =”“http://csvlife.com/wp-admin/”& “&安培; wordpress_test_cookie = 1”