2
我正在嘗試使用API(如C#Facebook SDK)發佈到facebook牆,而沒有。我得到正確的訪問令牌和所有這一切,但我發現了一個禁止使用403下面的代碼:ASP.NET發佈到Facebook牆壁
protected string postToWall()
{
var accessToken = Session["_FB_ACCESS_TOKEN"];
var graphId = Session["_FB_USER_GRAPH_ID"];
var url = string.Format(
"https://graph.facebook.com/{0}/feed",
graphId
);
var req = WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
string postData = string.Format(
@"curl -F 'access_token={0}' -F 'message=This is a test...' https://graph.facebook.com/{1}/feed",
accessToken,
graphId
);
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
var stream = req.GetRequestStream();
stream.Write(byteArray, 0, byteArray.Length);
stream.Close();
WebResponse response = req.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
return reader.ReadToEnd();
}
謝謝。我意識到curl是一個命令工具,我想也許它是在你將它作爲參數傳遞之後被調用的。哦,不要猜測。非常感謝! – Didaxis 2011-05-17 01:46:11
沒問題,祝你好運 – 2011-05-17 21:11:02
嘿..很好奇,如果你曾經把你的帖子發佈到facebook牆上工作..如果是這樣..想知道你是否可以分享你想出來的東西。 – jvcoach23 2013-05-09 19:35:22