Facebookのユーザーの代わりにグラフapiを使って壁に何かを投稿する方法をすでに知っていました。しかし、今私は自分のアプリケーションの名前で何かを投稿したい。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."
}
誰かが私が間違っているのを見ていますか?私は本当にこれに固執しています。
ありがとうございます!
あなたはどのような言語を使用しています。id = "stream_publish" とし、次のjQueryを使って
http://stackoverflow.com/questions/4641680/android-facebook-graph-api-to-update-status これはあなたも役に立ちます。ありがとう – SALMAN