HTML and CSS Reference
In-Depth Information
Step 4: Create a Facebook Config File
the RWA_Facebook class will be loaded on both the app's home page and the app's auth endpoint, so the
Facebook configuration details will be abstracted to a separate file. in the includes folder, create a new file
named fb_config.inc.php and put the following inside:
<?php
$fb_config = array(
'client_id' => '404595786243388',
'client_secret' => 'da2c599d9662ee744700dbfa483a154e',
'client_auth_endpoint'
=> ' http://rwa.cptr.us/exercises/05/01/login.php ',
'scope' => 'email',
);
this file is extremely simple: it defines an array, stored in $fb_config , that will be passed to the constructor of
the RWA_Facebook class when it is instantiated.
Make sure to replace client_id and client_secret with your app's credentials, because they are
domain-specific and will not work on domains for which they are not set up.
Note
Step 5: Create the App's Auth endpoint
now that all the classes and config files are in place, you can start building the actual pages for the app. Start by
creating the file login.php in web root. inside, place the following:
<?php
// Set error reporting to keep the code clean
error_reporting(E_ALL^E_STRICT);
ini_set('display_errors', 1);
// Loads the Facebook class
require_once 'includes/class.rwa_oauth.inc.php';
require_once 'includes/class.rwa_facebook.inc.php';
// Loads the $fb_config array
require_once 'includes/fb_config.inc.php';
$facebook = new RWA_Facebook($fb_config);
// If the user is logged in, send them to the home page
if ($facebook->is_logged_in()) {
 
 
Search WWH ::




Custom Search