0

我正在尝试在 Youtube 的私人消息中创建一个 Post Method。

继承人 URL “所有 url 都删除了点和 http://,以防止此问题作为垃圾邮件被阻止”

www_youtube_com/inbox?feature=mhee&folder=messages

在 C# 中,我已经创建了“登录”发布方法,下面是代码片段:

Dim url As String = "https://accounts.google.com/ServiceLogin?passive=true&hl=pt_BR&service=youtube&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26feature%3Dsign_in_button%26hl%3Dpt_BR%26next%3D%252F%26nomobiletemp%3D1&uilel=3"
Dim formUrl As String = url
Dim formParams As String = String.Format("Email={0}&Passwd={1}", "*********", "**********")
Dim cookieheader As String

Dim req As WebRequest = WebRequest.Create(formUrl)
req.ContentType = "application/x-www-form-urlencoded"
req.Method = "POST"
Dim bytes() As Byte = Encoding.ASCII.GetBytes(formParams)
req.ContentLength = bytes.Length
Using os As Stream = req.GetRequestStream()
    os.Write(bytes, 0, bytes.Length)
End Using
Dim resp As WebResponse = req.GetResponse()
cookieheader = resp.Headers("Set-cookie")
cookies.SetCookies(resp.ResponseUri, resp.Headers("Set-cookie"))
resp.Close()

'starts sending msg
Dim httpreq As HttpWebRequest = WebRequest.Create("http://www.youtube.com/inbox_ajax")
httpreq.ContentType = "application/x-www-form-urlencoded"
httpreq.Method = "POST"
formParams = String.Format("action_ajax=1&type=send_message&message_text={2}&subject={1}&to_users={0}&video_id={3}", "user", "subject", "message_body", "videoid")
bytes = Encoding.ASCII.GetBytes(formParams)
httpreq.ContentLength = bytes.Length
httpreq.CookieContainer = cookies
httpreq.Headers.Add("Cookie", cookieheader)
Using os As Stream = httpreq.GetRequestStream()
    os.Write(bytes, 0, bytes.Length)
End Using
resp = httpreq.GetResponse()

用户、主题、message_body 和 videoid 字段填充了真实数据以进行正确测试......

我已经尝试有时更改 HTTPREQ URL,因此它可以匹配 youtube 表单网站,但是,使用 firebug,我捕获了这些信息:

当我使用 Firebug 在 Firefox 中手动执行该帖子时出现的 URL:

www_youtube_com/inbox_ajax?action_ajax=1&type=send_message
Message Parameters:
[{"type":"send_message","request":{"message_text":"Test6","subject":"Test5","to_users":"HTDANILO","video_id":"ph0TNYQllRQ"}}]

萤火虫还说Referer站点是:

www_youtube_com/inbox?feature=mhee&folder=messages

但我已经尝试在那里发帖,也在http://www.youtube.com/inbox尝试过,但都没有成功。

有人可以指出我,所以我可以理解为什么它不起作用?

抱歉英语不好,不是我的母语,谢谢你的建议!

4

0 回答 0