Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store'n'load access token #8

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ CodeIgniter-Facebook

A complete library giving you facebook oauth authentication and graph api access.

Loesely based on:
[Elliot Haughin - CodeIgniter Facebook Library - Documentation](http://www.haughin.com/code/facebook/)
10 changes: 7 additions & 3 deletions application/config/facebook.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['facebook_app_id'] = '';
$config['facebook_api_secret'] = '';
$config['facebook_app_key'] = '';
$config['facebook_app_secret'] = '';
$config['facebook_default_scope'] = ''; // E.G 'read_stream,birthday,users_events,rsvp_event'
$config['facebook_api_url'] = 'https://graph.facebook.com/'; // Just in case it changes.
$config['facebook_api_url'] = 'https://graph.facebook.com/'; // Just in case it changes.

/* End of file facebook.php */
/* Location: ./application/config/facebook.php */
21 changes: 11 additions & 10 deletions application/controllers/facebook_test.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php
class Facebook_test extends CI_Controller {
class facebook_test extends CI_Controller {

function __construct()
{
parent::__construct();

// $this->load->add_package_path('/Users/elliot/github/codeigniter-facebook/application/');
$this->load->library('facebook');
$this->facebook->enable_debug(TRUE);
$this->load->library('facebook_api');
$this->load->helper('facebook');
$this->facebook_api->enable_debug(TRUE);
}

function index()
Expand All @@ -33,27 +34,27 @@ function index()
function login()
{
// This is the easiest way to keep your code up-to-date. Use git to checkout the
// codeigniter-facebook repo to a location outside of your site directory.
// codeigniter-facebook_api repo to a location outside of your site directory.
//
// Add the 'application' directory from the repo as a package path:
// $this->load->add_package_path('/var/www/haughin.com/codeigniter-facebook/application/');
//
// Then when you want to grab a fresh copy of the code, you can just run a git pull
// on your codeigniter-facebook directory.
// on your codeigniter-facebook_api directory.

if ( !$this->facebook->logged_in() )
if ( !$this->facebook_api->logged_in() )
{
// From now on, when we call login() or login_url(), the auth
// will redirect back to this url.

$this->facebook->set_callback(site_url('facebook_test'));
$this->facebook_api->set_callback(site_url('facebook_test'));

// Header redirection to auth.

$this->facebook->login();
$this->facebook_api->login();

// You can alternatively create links in your HTML using
// $this->facebook->login_url(); as the href parameter.
// $this->facebook_api->login_url(); as the href parameter.
}
else
{
Expand All @@ -63,7 +64,7 @@ function login()

function logout()
{
$this->facebook->logout();
$this->facebook_api->logout();
redirect('facebook_test');
}
}
Loading