YouTube - HttpWebRequests问题。 [英] YouTube - HttpWebRequests problem.
本文介绍了YouTube - HttpWebRequests问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请注意,我只是在练习HttpWebRequests知识。我只是想重新创建YouTube API。我不会使用它或重现它。
Please note that I am just practicing my HttpWebRequests knowledge. I am just trying to recreate the YouTube API. I will not use it or reproduce it.
我对HttpWebRequests有一些奇怪的问题。我设法登录,但是当我尝试订阅某个用户时,我从服务器收到此响应:远程服务器返回错误:(400)错误请求。
I have some weird problem with HttpWebRequests. I managed to login, but when I try to subscribe to some user I get this response from server: The remote server returned an error: (400) Bad Request.
Imports System.Net
Imports System.IO
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Web
Public Class Form1
Dim F As New Functions
Public Function GetBetween(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, Optional ByRef startPos As Integer = 0) As String
Dim iPos As Integer, iEnd As Integer, lenStart As Integer = strStart.Length
Dim strResult As String
strResult = String.Empty
iPos = strSource.IndexOf(strStart, startPos)
iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
If iPos <> -1 AndAlso iEnd <> -1 Then
strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
End If
Return strResult
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Source As String = F.HttpGet("https://www.google.com/accounts/ServiceLogin?uilel=3&service=youtube&passive=true&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Den_US%26next%3D%252F&hl=en_US&ltmpl=sso")
Dim DSH As String = vbNullString
DSH = GetBetween(Source, "id=" & Chr(34) & "dsh" & Chr(34), " />")
DSH = GetBetween(DSH, Chr(34), Chr(34))
Dim GALX As String = vbNullString
GALX = GetBetween(Source, "name=" & Chr(34) & "GALX" & Chr(34), " />")
GALX = GetBetween(GALX, Chr(34), Chr(34))
F.HttpPost("https://www.google.com/accounts/ServiceLoginAuth", "ltmpl=sso&pstMsg=&dnConn=&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Den_US%26next%3D%252Findex&service=youtube&uilel=3&dsh=" + DSH + "<mpl=sso&hl=en_US<mpl=sso&timeStmp=&secTok=&GALX=" + GALX + "&Email=Username&Passwd=Password&rmShown=1&signIn=Sign+in&asts=", "application/x-www-form-urlencoded")
Dim S As String = F.HttpGet("http://www.youtube.com/user/Chuubii")
Dim Session_Token As String = GetBetween(S, "data-subscription-xsrf=" + Chr(34), "==") + "=="
'Line under this is problem...
F.HttpPost("http://www.youtube.com/subscription_ajax?action_create_subscription_to_user=1&feature=channel", "u=Chuubii&menu_type=button&session_token=" + Session_Token, "application/x-www-form-urlencoded")
End Sub
End Class
推荐答案
BUMP。我真的需要这个。
BUMP. I really need this.
这篇关于YouTube - HttpWebRequests问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文