2011-10-06 59 views
0

我讀了this documentation並使用了那裏給出的代碼。除了我嘗試發送的消息外,一切正常。消息似乎在牆上是空的。發佈到Facebook上的.NET牆上(發送的消息是空的)

accessUrl是正確的,所以消息被髮送。

SendHttpRequest(accessUrl, "message = This is a test", HttpMethodsEnum.POST); 

這是我以前

public virtual string SendHttpRequest(string Url, string Request, HttpMethodsEnum MethodType = HttpMethodsEnum.POST) 
    { 

     HttpWebRequest webRequest = null; 
     StreamWriter requestWriter = null; 
     string responseData = ""; 

     webRequest = System.Net.WebRequest.Create(Url) as HttpWebRequest; 
     webRequest.Method = MethodType.ToString(); 
     webRequest.ServicePoint.Expect100Continue = false; 
     webRequest.UserAgent = "[You user agent]"; 
     webRequest.Timeout = 20000; 

     if (MethodType == HttpMethodsEnum.POST) 
     { 
      webRequest.ContentType = "application/x-www-form-urlencoded"; 

      requestWriter = new StreamWriter(webRequest.GetRequestStream()); 

      try 
      { 
       requestWriter.Write(Request); 
      } 
      catch 
      { 
       throw; 
      } 

      finally 
      { 
       requestWriter.Close(); 
       requestWriter = null; 
      } 
     } 
     StreamReader streamReader = null; 
     try 
     { 
      streamReader = new StreamReader(webRequest.GetResponse().GetResponseStream()); 
      responseData = streamReader.ReadToEnd(); 
     } 
     catch 
     { 
      throw; 
     } 
     finally 
     { 
      webRequest.GetResponse().GetResponseStream().Close(); 
      streamReader.Close(); 
      streamReader = null; 
     } 

     return responseData; 

    } 
+0

從您的帖子中取消了1條,因爲您沒有回來結束該故事。 SO垃圾。 –

回答

相關問題