1

从今天早上(现在超过 8 小时)开始,我一直在尝试解决一个问题。我得到了 facebook cookie 内容,找到了在浏览器中可以正常工作的身份验证令牌

https://graph.facebook.com/me?access_token=201856003211297|2.AQAHJg3GugHIHhec.3600.1314442800.1-100002411647354|RAylZSUax4pdKcIt--QruS-Qcgc

每当我尝试获取用户信息时,网页都会很好地崩溃并出现以下错误。

我尝试使用网络请求从页面中读取:

    'Dim inputFile As String = "https://graph.facebook.com/me?access_token=" & access_token
    'Dim sDiskFile As String = "auth.txt"

    'Dim _wrequest As WebRequest = WebRequest.Create(inputFile)
    'Dim _wresponse As WebResponse

    '_wresponse = _wrequest.GetResponse()

    'Dim _stream As Stream = _wresponse.GetResponseStream()

    'Dim oReader As New StreamReader(_stream, Encoding.ASCII)

它因同样的错误而崩溃。我决定试一试 Facebook SDK 5,但同样的错误发生了:

    Dim access_token As String = GetFacebookTokenFromCookie()
    If access_token = "" Then
        litUser.Text = "<fb:login-button perms='email'>Login with Facebook</fb:login-button>"
    Else

        Dim app As New DefaultFBApp
        Dim _ctx As New FacebookWebContext(app)

        Dim fb As New Facebook.FacebookClient(app)
        fb.AccessToken = access_token

        Dim parameters As New Dictionary(Of String, Object)()
        parameters("fields") = "id,name"

        Dim result As Object = fb.Get(parameters)

        Dim id = result.id
        Dim name = result.name
        Dim firstName As String = result.first_name
        Dim lastName = result.last_name
        Dim link = result.link
        Dim username = result.username
        Dim gender = result.gender
        Dim male = result.locale
        litUser.Text = "Welcome " & firstName
    End If

DefaultFBApp is:

    Public Class DefaultFBApp
        Implements Facebook.IFacebookApplication

添加了所有必须实现的字段并填写了 api 密钥和秘密。

同样的错误:

Server Error in '/' Application.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 69.171.224.21:443

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 69.171.224.21:443

Source Error:

Line 25:             parameters("fields") = "id,name"
Line 26:             
Line 27:             Dim result As Object = fb.Get(parameters)
Line 28:  
Line 29:             Dim id = result.id


Source File: masterpage.master    Line: 27

Stack Trace:

[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 69.171.224.21:443]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
   System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224

[WebExceptionWrapper: Unable to connect to the remote server]
   FluentHttp.HttpHelper.OpenRead() +191
   Facebook.FacebookClient.Api(String path, IDictionary`2 parameters, HttpMethod httpMethod, Type resultType) +253
   Facebook.FacebookClient.Get(IDictionary`2 parameters) +44
   ASP.masterpage_master.Page_Load(Object sender, EventArgs e) in E:\kunden\homepages\6\d364763622\www\wsb6301158401\masterpage.master:27
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

版本信息:Microsoft .NET Framework 版本:2.0.50727.5446;ASP.NET 版本:2.0.50727.5420

任何帮助将不胜感激

4

0 回答 0