So I have been working on this problem for the better part of two weeks now and nothing that I do seems to bring me any closer to solving the problem. I am trying to implement a system where I can signin to facebook and authenticate the user with one button click. The problem arrises when that button has to submit to facebook to bring authenticated data to the client, and then I need to work with post-back to get that data to the server to authenticate it on my end.
The button works fine. The post-back works fine as well (I can verify that I can MAKE an ajax request via alerts and the like). The problem I'm having is setting up the server to accept an ajax request; and then formatting the client to send it to the proper URL.
I've attempted to run through RESTextentions, make custom ASPX pages, etc. I would appreciate ANY help on this.
I want to have the fb_redirect page return SOMETHING. It can be anything, and then have that displayed as an alert on the client side. Once that happens I can figure out the rest; but it's that initial connection/post-back that I need help on.
AJAX Requests Assistance
Hey all!
So I have been working on this problem for the better part of two weeks now and nothing that I do seems to bring me any closer to solving the problem. I am trying to implement a system where I can signin to facebook and authenticate the user with one button click. The problem arrises when that button has to submit to facebook to bring authenticated data to the client, and then I need to work with post-back to get that data to the server to authenticate it on my end.
The button works fine. The post-back works fine as well (I can verify that I can MAKE an ajax request via alerts and the like). The problem I'm having is setting up the server to accept an ajax request; and then formatting the client to send it to the proper URL.
I've attempted to run through RESTextentions, make custom ASPX pages, etc. I would appreciate ANY help on this.
Here is my client-side code:
window.fbAsyncInit = function () {
FB.init({
appId: '324182087714410', // App ID
channelUrl: '//localhost:12227//channel.html', // Channel File
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
FB.Event.subscribe('auth.login', function (response) {
alert("logged in boss");
});
FB.Event.subscribe('auth.logout', function (response) {
});
FB.Event.subscribe('auth.authResponseChange', function (response) {
// Here we specify what we do with the response anytime this event occurs.
if (response.status === 'connected') {
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
getData();
alert("6");
} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
}
});
};
(function (d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function getData() {
FB.getLoginStatus(function (response) {
var accessToken = response.authResponse.accessToken;
$.ajax({
type: "POST",
url: "fb_redirect",
data: '{"field1":"43"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert("SUCCESS!");
},
error: function(data, status, jqXHR) {
alert(data);
}
});
});
}
Here is the contents of fb_redirect.master:
<%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
<form runat="server">
<umbraco:Macro Alias="fb_Redirect" runat="server" />
</form>
</asp:Content>
is working on a reply...