SOF でよく検索しましたが、私の問題に対する答えが見つからなかったので、新しいスレッドを作成します。私は Facebook アプリケーションに取り組んでおり、ユーザーが接続されているかどうかをテストしたいと考えています。そうでない場合は、ログイン用の facebook ポップアップが必要ですが、必要なものを取得することはできません。
コードは次のとおりです。
私は多くのことを試しました:
String AppID = System.Configuration.ConfigurationManager.AppSettings["FB_appId"];
String redirect_uri = Controller.GetCurrentPageFacebookPublishedPath(this.Request);
Response.Redirect("https://www.facebook.com/login.php?client_id=" + AppID +
"&redirect_uri=" + redirect_uri + "&display=popup");
またはこれ:
FacebookClient client = new FacebookClient();
Dictionary<string, object> PostParameters = new Dictionary<string, object>();
PostParameters.Add("client_id", AppID);
PostParameters.Add("display", "popup");
PostParameters.Add("redirect_uri", redirect_uri);
//object res = client.Post("https://www.facebook.com/dialog/oauth", PostParameters);
object res = client.Get("https://www.facebook.com/login.php", PostParameters);
しかし、何も機能しません...
私が間違っていることがありますか?これをjavascriptで行う必要がありますか?
編集 :
私は最終的にC#で解決策を見つけられなかったので、そのようなjavascriptを使用しました:
FB.getLoginStatus(function (response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
} else {
$(".myBouton").click(function () {
FB.login(function (response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function (response) {
console.log('Good to see you, ' + response.name + '.');
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
});
});
}
});
しかし、その後に関数を呼び出す方法がわかりません。さまざまなボタンがたくさんあり、もちろんユーザーログとリダイレクトの後にアクションを実行したいからです。