我試圖用這個方法來發布照片到Facebook塗鴉牆。Facebook的圖形API塗鴉牆
/// <param name="method">Http Method</param>
/// <param name="url">Full url to the web resource</param>
/// <param name="postData">Data to post in querystring format</param>
/// <returns>The web server response.</returns>
public string WebRequest(Method method, string url, string postData)
{
HttpWebRequest webRequest = null;
StreamWriter requestWriter = null;
string responseData = "";
webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
webRequest.Method = method.ToString();
webRequest.ServicePoint.Expect100Continue = false;
webRequest.UserAgent = "[]";
webRequest.Timeout = 20000;
if (method == Method.POST)
{
webRequest.ContentType = "application/x-www-form-urlencoded";
requestWriter = new StreamWriter(webRequest.GetRequestStream());
try
{
requestWriter.Write(postData);
}
catch
{
throw;
}
finally
{
requestWriter.Close();
requestWriter = null;
}
}
responseData = WebResponseGet(webRequest);
webRequest = null;
return responseData;
}
什麼我遇到的問題是POSTDATA。我無法讓它工作,我不確定那個字符串會是什麼樣子?任何人都可以舉個例子嗎?
是否有錯誤?你的意思是「我無法讓它工作?」 – 2012-04-26 12:57:57
什麼都沒有發佈。它一次給牆上貼了一條消息,但就是這樣。 – 2012-04-26 13:26:09
你有沒有有效的令牌?它可能會過期嗎? – avs099 2012-04-30 12:05:42