Youtube通过邮件发送私人消息

时间:2012-12-22 05:51:06

标签: c# vb.net http post youtube

我正在尝试在Youtube的私信中制作帖子方法。

继承人的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网址,因此它可以匹配youtube表单网站,但是,使用firebug,我会抓住这些信息:

使用Firebug在Firefox中手动执行此操作时发生的帖子:

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尝试过,但都没有用。

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

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

0 个答案:

没有答案