I searched a lot on SOF but didn't find an answer to my problem, so I create a new thread.
I'm working on a Facebook Application, and want ton test if the user is connected, or not.
If he's not, I want to have the facebook Popup for the login, but it's impossible for me to obtain what I want.
Here is the code :
I tried a lot of things :
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");
Or this :
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);
But nothing works...
Is there something i do wrong? Should I do this in javascript ?
EDIT :
I finally didn't find a solution in c#, so I used javascript like that :
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.');
}
});
});
}
});
But I don't know how to call a function after that, because I have a lot of different buttons, and I want my actions being done, after the User log and redirection of course.
No comments:
Post a Comment