https://github.com/bvrignaud/ci-fb-ion-auth
Facebook library for CodeIgniter with Ion-Auth
https://github.com/bvrignaud/ci-fb-ion-auth
codeigniter facebook ion-auth
Last synced: 4 days ago
JSON representation
Facebook library for CodeIgniter with Ion-Auth
- Host: GitHub
- URL: https://github.com/bvrignaud/ci-fb-ion-auth
- Owner: bvrignaud
- License: mit
- Created: 2017-08-22T18:39:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-07T21:49:17.000Z (about 6 years ago)
- Last Synced: 2025-04-17T16:04:09.819Z (9 days ago)
- Topics: codeigniter, facebook, ion-auth
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 7
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ci-fb-ion-auth
This is a php and CodeIgniter (3.x) library to use Facebook php SDK with Ion-Auth.## Requirements
- PHP 5.4.0 or later (5.6 or later is recommended)
- [CodeIgniter 3](https://www.codeigniter.com/)
- [CodeIgniter session library](https://www.codeigniter.com/userguide3/libraries/sessions.html)
- [Ion-Auth] (http://benedmunds.com/ion_auth/)
- [Facebook PHP SDK v5](https://developers.facebook.com/docs/php/gettingstarted/5.0.0)
- [Composer](https://getcomposer.org/)## Installation
Install the Facebook PHP SDK with Composer with `composer install` ([Read more](https://developers.facebook.com/docs/php/gettingstarted#install-composer)) :
```sh
$ cd /path/to/codeigniter_project/
$ composer require facebook/graph-sdk
```
In your CodeIgniter `/application/config/config.php` file, set `$config['composer_autoload']` to `TRUE`. [Read more](https://www.codeigniter.com/user_guide/general/autoloader.html).Copy the files from this package to the corresponding folder in your application folder. For example, copy application/config/facebook.php to application/config/facebook.php
You can also copy the libraries and models directories into your third_party/ci-fb-ion-auth folder. For example, copy to /application/third_party/ci-fb-ion-auth/. The directory structure would be :
config/facebook.php
third_party/ci-fb-ion-auth/helpers/facebook_helper.php
third_party/ci-fb-ion-auth/libraries/Facebook.php
third_party/ci-fb-ion-auth/models/Facebook_model.php
Only the library, model and config files are required.Edit your `facebook.php` config file in `/application/config/facebook.php` with your Facebook App details.
Autoload the library in `application/config/autoload.php` or load it in needed controllers with `$this->load->library('facebook');`.
Autoload the helper in `application/config/autoload.php` or load it in needed controllers with `$this->load->helper('facebook_helper');`.
## Relational DB Setup
Run the SQL file `sql/ci-fb-ion-auth`.## Usage
In the package you will find simple example usage code in the controllers and views folders.### Register with Facebook
view:```php
Register with Facebook
```
controller (welcome.php):```php
public function fb_register_callback()
{
if ($this->facebook->fb_callback()) {
redirect('user/account');
} else {
show_error('erreur');
}
}
```### Connexion with Facebook
view:```php
Connexion with Facebook
```
controller (welcome_fb_ion_auth.php):```php
public function fb_login_callback()
{
if ($this->facebook->fb_callback()) {
echo 'Your are now logged in !";
} else {
show_error('erreur');
}
}
```
### Connect/Disconnect user's Facebook account
view :
```php
if ($this->ion_auth->logged_in()) {
if ($this->ion_auth->user()->row()->idfacebook_user) {
echo '
Disconnect my Facebook account
';
} else {
echo '
Connect my Facebook account
';
}
}
```
controller (welcome.php):```php
public function disconnectFacebookAccount_callback()
{
$this->facebook->disconnectFacebookAccount();
redirect();
}public function connectFacebookAccount_callback()
{
$this->facebook->connectFacebookAccount();
redirect();
}
```