This tutorial shows how to implement a “Continue with Facebook” button just PHP. No JS required.
If you prefer to render the button with JS, see my other tutorial.
JS vs PHP rendering:
This tutorial uses PHP to render the button. There are pros/cons compared to a JS version:
- More coding;
- Vulnerable to future API “breaking changes”
- It works on Firefox private mode;
- It works with “Facebook Container” plugin (it shows the button);
0. Create an app on FB’s developer:
Create an app:
Get the ID and SECRET:
1. Install PHP SDK on your project folder:
cd my-project composer require facebook/graph-sdk
2. The code:
Save this code on a file (ex.
test-fb.php) run it on a server (ex.
php -S localhost:3000) and open it in your browser.
The code is self-explanatory. But let me know in the comments if you think it is not.
After testing, you need to publish your FB app: