magic2goodil Posted January 14, 2007 Share Posted January 14, 2007 I posted about this code a minute ago, it works now, but is not passing the key and next variables to the address bar when it takes you to facebook's login...Can anyone tell me what I did wrong in this code?[code]<?phpclass cbx_facebookAPI {// ### Class Variables var $config; // array to hold API variablesvar $facebook; // holds Facebook object var $session; // holds Facebook sessionvar $user_info; // array to hold Facebook User Info before fixvar $user; // array to hold fixed user information // ### cbx_facebookAPI class construct ### function __construct() { // ### Registered API Variables ### $this->config = array(); $this->config['api_key'] = "fab265688ad5a13ec15b61477e2f0afd"; $this->config['secret'] = "***********"; $this->config['next'] = 'index.php'; } // ### End __construct() ### // ### Make Connection and Pull User Info from Facebook ### function doConnect() { // ##### INCLUDE CLASS ##### include('facebook.php'); if (!empty($_REQUEST['auth_token'])) { // ##### INITIATE FACEBOOK CLASS ##### $this->facebook = new Facebook ($this->config['api_key'], $this->config['secret'], null, false, false, false); // ##### SET SESSION INFORMATION ##### $this->session = $this->facebook->auth_getSession ($_REQUEST['auth_token']); // ##### SET COOKIES ##### setcookie('facebook_session_key', $this->session[0]['elements'][0]['text']); setcookie('facebook_uid', $this->session[0]['elements'][1]['text'], time()+60*60*24); // ##### REDIREC TO CHAT ##### header('Location: ' . $_SERVER['PHP_SELF']); } // End IF else { // ##### CHECK FOR USER LOGGED IN ##### if (empty($_COOKIE['facebook_session_key'])) { // ##### REQUIRE LOGIN ##### header('Location: http://api.facebook.com/login.php?api_key=' . $this->config['api_key'] . '&next=' . $this->config['next']); } // End IF // ##### INITIATE CLASS ##### $this->facebook = new Facebook ($this->config['api_key'], $this->config['secret'], $_COOKIE['facebook_session_key']); // ##### PULL USER INFO ##### $this->user_info = $this->facebook->users_getInfo ($_COOKIE['facebook_uid'], 'first_name,last_name,current_location,affiliations'); $this->user = array(); $this->user['firstname'] = $this->user_info[0]['elements'][0]['elements'][0]['text']; $this->user['lastname'] = $this->user_info[0]['elements'][0]['elements'][1]['text']; // ##### CHECK FOR EXPIRED SESSION ##### if ($username == '102_Session key invalid or no longer valid') { setcookie('facebook_session_key', ''); setcookie('facebook_uid', ''); header('Location: ' . $_SERVER['PHP_SELF']); print_r($_COOKIE); } // End IF } // End Else } // ### End doConnect() ### // ### GET USER INFO FUNCTION ### function get_userinfo() { return $this->user; }} // End cbx_facebookAPI class?>[/code]I am calling this class object on [url=http://www.collegebookx.com/registerAPI/index.php]http://www.collegebookx.com/registerAPI/index.php[/url]The code is here for the call to it:[code]<?phprequire_once('cbx_facebookAPI.class.php');$t = new cbx_facebookAPI();$t->doConnect();$user = $t->get_userinfo();print_r($user);?>[/code]If you goto the url posted above, you'll see it takes you to facebook login without my api code nor the next..I'm not that great with classes in php yet, am I initializing/calling them incorrectly? Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/ Share on other sites More sharing options...
magic2goodil Posted January 14, 2007 Author Share Posted January 14, 2007 mostly I am just wondering if the way i am calling the $config[] array variables in doConnect() is correct or not. for some reason when passing them in doConnect() to the url for facebook, they go in empty.. Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/#findComment-160162 Share on other sites More sharing options...
magic2goodil Posted January 14, 2007 Author Share Posted January 14, 2007 :( nobody? Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/#findComment-160185 Share on other sites More sharing options...
magic2goodil Posted January 14, 2007 Author Share Posted January 14, 2007 *pouts* ??? Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/#findComment-160226 Share on other sites More sharing options...
magic2goodil Posted January 14, 2007 Author Share Posted January 14, 2007 -bump Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/#findComment-160346 Share on other sites More sharing options...
Philip Posted January 14, 2007 Share Posted January 14, 2007 Well, on line 70 you're telling it to redirect to the login page for facebook in the function do_connect. Then your calling it in "$t->doConnect();" [code]// ##### CHECK FOR USER LOGGED IN ##### if (empty($_COOKIE['facebook_session_key'])) { // ##### REQUIRE LOGIN ##### header('Location: http://api.facebook.com/login.php?api_key=' . $this->config['api_key'] . '&next=' . $this->config['next']); } // End IF[/code]I could be wrong, but I think that's where you're going wrong. I'm no expert in classes though. Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/#findComment-160348 Share on other sites More sharing options...
magic2goodil Posted January 14, 2007 Author Share Posted January 14, 2007 it manages to redirect, but $this->config['api_key'] and next aren't being passed at all.. Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/#findComment-160351 Share on other sites More sharing options...
magic2goodil Posted January 14, 2007 Author Share Posted January 14, 2007 thought perhaps this would be a simple topic for someone :( Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/#findComment-160393 Share on other sites More sharing options...
magic2goodil Posted January 14, 2007 Author Share Posted January 14, 2007 -bump bump- Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/#findComment-160647 Share on other sites More sharing options...
magic2goodil Posted January 14, 2007 Author Share Posted January 14, 2007 u all suck :( and i do too for not being able to figure this out :( Quote Link to comment https://forums.phpfreaks.com/topic/34069-facebook-api-help/#findComment-160696 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.