1

I am using HybridAuth to authenticate my social apps through PHP. Using Facebook as an example, I want to send a notification to a user.

When HybridAuth connects to Facebook, it needs to go to the website to allow the connection and then it redirects the browser back to the page that it was on.

The problem is when I am running PHP through AJAX. I'm not sure what is happening but the API call is not run and a notification is not sent. The problem must lie in leaving the AJAX script to connect the social network and not being able to continue with the code.

Any thoughts here?

Jason Lipo
  • 751
  • 2
  • 11
  • 24

2 Answers2

0

The problem is when I am running PHP through AJAX. I'm not sure what is happening but the API call is not run and a notification is not sent.

  1. Redirection doesn't work on Ajax calls. You have to change the coding style here.

  2. There are already 100s of examples out there on how to write such scripts that provides login using facebook. So I'd consider skipping it, since that'll be really broad.

  3. Please try and then come up with some specific issue, we'll be more than glad to help you out. Also, always consider posting a SSCCE to clarify what exactly you tried.

coding_idiot
  • 13,526
  • 10
  • 65
  • 116
0

As @coding_idiot stated, authentication won't work in AJAX calls, since authentication requires redirecting the user to the provider. The backend script will die() in the Redirect function.

For an alternative solution, check this approach: https://stackoverflow.com/a/29891358/1816603

Community
  • 1
  • 1
Jose Gómez
  • 3,110
  • 2
  • 32
  • 54