Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OAUTH VB.NET雅虎电子邮件验证程序_Vb.net_Email_Oauth_Yahoo_Yql - Fatal编程技术网

OAUTH VB.NET雅虎电子邮件验证程序

OAUTH VB.NET雅虎电子邮件验证程序,vb.net,email,oauth,yahoo,yql,Vb.net,Email,Oauth,Yahoo,Yql,我们有一个使用vb.net的oauth yahoo电子邮件验证器的小项目,我们对oauth实现非常陌生,想问一下我们的代码是否正确,我们没有收到服务器的响应,希望我们能在这里得到一些很好的答案,提前谢谢 以下是所附代码 Option Explicit On Option Strict On Public Class frmValidator Public Const YahooAppID As String = "yPh6rr56" 'pfswebdev@yahoo.com/pfsw

我们有一个使用vb.net的oauth yahoo电子邮件验证器的小项目,我们对oauth实现非常陌生,想问一下我们的代码是否正确,我们没有收到服务器的响应,希望我们能在这里得到一些很好的答案,提前谢谢

以下是所附代码

Option Explicit On
Option Strict On

Public Class frmValidator

    Public Const YahooAppID As String = "yPh6rr56" 'pfswebdev@yahoo.com/pfsweb123 
    Public Const YahooConsumerKey As String = "dj0yJmk9Qkw3VWFZcXA0V1ZNJmQ9WVdrOWVWQm9Obkp5TlRZbWNHbzlNakEzTWpNek5qVTJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD0wNA--"
    Public Const YahooConsumerSecret As String = "80e148890ec0a31da518013998fbbfd49b996296"
    Public Const YQLAddress As String = "http://query.yahooapis.com/v1/public/yql"

    Public Shared Function VerifyYahooAccount(ByVal emailAddress As String) As String
        Dim yahooID As String = emailAddress.Substring(0, emailAddress.IndexOf("@"))
        Dim restURL As String = "http://query.yahooapis.com/v1/yql?q=%20select%20*%20from%20social.profile%20where%20guid%20in%20(select%20guid%20from%20yahoo.identity%20where%20yid%20%3D%20'" & yahooID & "')&diagnostics=false"
        Dim requestUrl As String = ""
        Dim normalizedUrl As String = ""
        Dim normalizedUrlParams As String = ""

        Dim provider As OAuth.OAuthBase = New OAuth.OAuthBase()
        Dim signature As String = provider.GenerateSignature(New Uri(restURL), YahooConsumerKey, YahooConsumerSecret, "", "", "GET", provider.GenerateTimeStamp(), provider.GenerateNonce(), normalizedUrl, normalizedUrlParams)
        requestUrl = normalizedUrl & "?" & normalizedUrlParams & "&" & Web.HttpUtility.UrlEncode("oauth_signature") & "=" & Web.HttpUtility.UrlEncode(signature)

        Dim context As New Consumer.OAuthConsumerContext()
        With context
            .ConsumerKey = YahooConsumerKey
            .ConsumerSecret = YahooConsumerSecret
            .SignatureMethod = DevDefined.OAuth.Framework.SignatureMethod.HmacSha1
            .UseHeaderForOAuthParameters = True
        End With

        Dim session As New Consumer.OAuthSession(context, "https://api.login.yahoo.com/oauth/v2/get_request_token", "https://api.login.yahoo.com/oauth/v2/request_auth", "https://api.login.yahoo.com/oauth/v2/get_token")

        Dim response As HttpWebResponse = session.Request.Get().ToWebResponse()

        Dim xdoc As System.Xml.Linq.XDocument = New Consumer.ConsumerRequest(Nothing, Nothing, Nothing).GetRequestDescription


        Dim responseData As String = ""
        Try
            Dim hwrequest As Net.HttpWebRequest = CType(Net.WebRequest.Create(requestUrl), Net.HttpWebRequest)
            hwrequest.Accept = "text/xml"
            hwrequest.AllowAutoRedirect = True
            hwrequest.Timeout = 60000
            hwrequest.Method = "GET"

            Dim hwresponse As Net.HttpWebResponse = CType(hwrequest.GetResponse(), Net.HttpWebResponse)
            If hwresponse.StatusCode = Net.HttpStatusCode.OK Then
                Dim responseStream As IO.StreamReader = _
                  New IO.StreamReader(hwresponse.GetResponseStream())
                responseData = responseStream.ReadToEnd()
            End If
            hwresponse.Close()
        Catch e As Exception
            responseData = "An error occurred: " & e.Message
        End Try

    End Function

    Private Sub btnValidate_Click(sender As System.Object, e As System.EventArgs) Handles btnValidate.Click
        VerifyYahooAccount(txtValidate.Text.ToString)
    End Sub
End Class