تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] مشكلة فى عمل اتصال بالويب ريكسوت والضغط على زر
#1
احاول جلب الاكسس توكن

من هذا الرابط
http://bit.ly/MG-HTC0

افتح الرابط فى متصفح فايرفوكس هتلاقيه بيظهرلك رسالة وفيها زر موافق

وعند الضغط على زر موافق يظهرلك الاكسس توكن فى الرابط

مشكلتى الحالية انى مش عارف اضفط على زر موافق هذا عبر الويب ريكسوت

وحاليا بجيب التوكن عبر هذا الكود

من سورس الصفحة قبل الضغط على زر موافق

ولكن المشكلة انه يكون غير قابل للاستخدام الا بعد الضغط على زر موافق

اتمنى ان تكون المشكلة واضحة لكم

واتمنى من لديه حل لا يبخل


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim s As String = String.Format("email={0}&pass={1}", WebUtility.UrlEncode(u.Text), WebUtility.UrlEncode(p.Text))
Dim bytes As Byte() = New UTF8Encoding().GetBytes(s)
Dim req As HttpWebRequest = WebRequest.Create("https://m.facebook.com/login.php")
req.Method = "POST"
req.CookieContainer = mycontainer2
req.ContentType = "application/x-www-form-urlencoded"
req.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:47.0) Gecko/20100101 Firefox/47.0"
req.ContentLength = bytes.Length
Using reqStrm = req.GetRequestStream()
reqStrm.Write(bytes, 0, bytes.Length)
End Using
Using res = req.GetResponse()
Using resStrm = res.GetResponseStream()
Using rdr As New StreamReader(resStrm)
Dim responseString As String = rdr.ReadToEnd()
End Using
End Using
End Using
If rhtc.Checked Then
get_htc()
ElseIf rsmart.Checked Then
'get_smart()
Else
MsgBox("اختار تطبيق اولا")
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Sub get_htc()
Dim firstRedirect As String = getLocation("http://bit.ly/MG-HTC0")
If firstRedirect.StartsWith("~EX") Then
MessageBox.Show(firstRedirect.Substring(3))
Return
End If
Dim token As String = getToken(firstRedirect)
If token.StartsWith("~EX") Then
MessageBox.Show(token.Substring(3))
Else
Dim fb As New FacebookClient(token)
Dim name = fb.Get("me").name()
Dim Li As ListViewItem
Li = frm_accounts.userslist.Items.Add(name)
Li.SubItems.Add(token)
End If
End Sub
Private Function getLocation(ByVal URL As String)
Try
Dim req As HttpWebRequest = WebRequest.Create(URL)
req.Method = "GET"
req.CookieContainer = mycontainer2
req.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:47.0) Gecko/20100101 Firefox/47.0"
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
req.ContentType = "application/x-www-form-urlencoded"
req.AllowAutoRedirect = False
Using res = req.GetResponse
Return res.Headers("Location")
End Using
Catch ex As Exception
Return "~EX" & ex.Message
End Try
End Function
Private Function getToken(ByVal URL As String)
Try
Dim req As HttpWebRequest = WebRequest.Create(URL)
req.Method = "GET"
req.CookieContainer = mycontainer2
req.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:47.0) Gecko/20100101 Firefox/47.0"
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
req.ContentType = "application/x-www-form-urlencoded"
Using res = req.GetResponse()
Using resStrm = res.GetResponseStream()
Using rdr As New StreamReader(resStrm)
Dim resString As String = rdr.ReadToEnd()
Return Regex.Match(resString, """accessToken"":""(.+?)""", RegexOptions.IgnoreCase).Groups(1).Value
End Using
End Using
End Using
Catch ex As Exception
Return "~EX" & ex.Message
End Try
End Function
الرد }}}
تم الشكر بواسطة:
#2
هو مفيش ردود ليه Big Grin

الرسالة الى بتظهر عند فتح الرابط من فيرفوكس
الرد }}}
تم الشكر بواسطة:
#3
مادام الامر يخص فيس بوك ....لويش حاط رابط آخر يحول الى فيس بوك؟؟؟
الرد }}}
تم الشكر بواسطة: الماجيك مسعد
#4
(28-07-16, 12:08 AM)سعود كتب : مادام الامر يخص فيس بوك ....لويش حاط رابط آخر يحول الى فيس بوك؟؟؟
لم افهم قصدك شو الرابط الى بيحول تانى للفيس بوك؟
الرد }}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم