我已經找到了如何使用圖表api代表facebook用戶向牆上發佈內容。但是現在我想以我的應用程序的名義發佈一些內容。我的Facebook應用程序如何將消息發佈到牆上?
這裏是如何我試圖做到這一點:
protected void btn_submit_Click(object sender, EventArgs e)
{
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("message", "Testing");
// i'll add more data later here (picture, link, ...)
data.Add("access_token", FbGraphApi.getAppToken());
FbGraphApi.postOnWall(ConfigSettings.getFbPageId(), data);
}
FbGraphApi.getAppToken()
// ...
private static string graphUrl = "https://graph.facebook.com";
//...
public static string getAppToken() {
MyWebRequest req = new MyWebRequest(graphUrl + "/" + "oauth/access_token?type=client_cred&client_id=" + ConfigSettings.getAppID() + "&client_secret=" + ConfigSettings.getAppSecret(), "GET");
return req.GetResponse().Split('=')[1];
}
FbGraphApi.postOnWall()
public static void postOnWall(string id, Dictionary<string,string> args)
{
call(id, "feed", args);
}
FbGraphApi.call( )
private static void call(string id, string method, Dictionary<string,string> args)
{
string data = "";
foreach (KeyValuePair<string, string> arg in args)
{
data += arg.Key + "=" + arg.Value + "&";
}
MyWebRequest req = new MyWebRequest(graphUrl +"/" + id + "/" + method, "POST", data.Substring(0, data.Length - 1));
req.GetResponse(); // here i get: "The remote server returned an error: (403) Forbidden."
}
有沒有人看到我在哪裏出錯?我真的堅持這一點。
謝謝!
您使用什麼語言? – Shaz 2011-04-16 14:56:05
http://stackoverflow.com/questions/4641680/android-facebook-graph-api-to-update-status 這也會幫助你。謝謝 – SALMAN 2011-11-22 16:20:23