【问题标题】:Facebook graph API returns time out exception while authorizeFacebook 图形 API 在授权时返回超时异常
【发布时间】:2013-07-12 06:22:44
【问题描述】:
(HttpWebRequest)WebRequest.Create(string.Format(“https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}”, strClientID, “http://www.facebook.com/connect/login_success.html”));

我正在使用此代码。

但是我得到的操作已经超时错误。

你能帮我解决这个问题吗?

这是我的同事

 getRequest = (HttpWebRequest)WebRequest.Create(string.Format("https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}", strClientID, "http://www.facebook.com/connect/login_success.html"));

            getRequest.Method = WebRequestMethods.Http.Get;
            getRequest.CookieContainer = request.CookieContainer;
            getRequest.CookieContainer.Add(cookies);
            getRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
            getRequest.AllowWriteStreamBuffering = true;
            //getRequest.ProtocolVersion = HttpVersion.Version11;
            getRequest.AllowAutoRedirect = true;
            getRequest.ContentType = "application/x-www-form-urlencoded";

            //byteArray = Encoding.ASCII.GetBytes(postData);
            //getRequest.ContentLength = byteArray.Length;
            //newStream = getRequest.GetRequestStream(); //open connection
            //newStream.Write(byteArray, 0, byteArray.Length); // Send the data.

我从这段代码中得到了这个错误

 getResponse = (HttpWebResponse)getRequest.GetResponse();

请尽快帮助我。感谢所有的 cmets 和回复。

提前谢谢..

【问题讨论】:

    标签: c# asp.net facebook-graph-api timeout authorization


    【解决方案1】:

    问题是我们一次只能使用一个 HttpWebResponse。就我而言,我两次使用同一个对象而没有任何处置和关闭。这让我犯了错误。

    所以我像这样更新了我的代码。

     byteArray = Encoding.ASCII.GetBytes(postData);
            getRequest.ContentLength = byteArray.Length;
            newStream = getRequest.GetRequestStream(); //open connection
            newStream.Write(byteArray, 0, byteArray.Length); // Send the data.
    
            getResponse = (HttpWebResponse)getRequest.GetResponse();
            getresponse.Close();
    

    这解决了我的错误。谢谢

    【讨论】:

      猜你喜欢
      • 2011-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多