eariass Posted December 2, 2011 Share Posted December 2, 2011 How can I know the Facebook user ID when a user visit my fanpage before she/he click like button. I want to show "hello XXXXXXX" when enter to my landing tab. This is my code but not show nothing... $app_id = "xxxxxxxxxxxxxxxxxxxxx"; $app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxx"; include_once 'facebook.php'; global $api_id,$app_secret; $fb=new Facebook($api_id,$app_secret); $fb_user=$fb->get_loggedin_user(); echo $fb_user; ?> Quote Link to comment Share on other sites More sharing options...
Zephni Posted December 2, 2011 Share Posted December 2, 2011 Hi, Just scanning through the Facebook dev site it looks like the call you are looking for is this: $uid = $facebook->getUser(); This will return the ID, with the id you can call more information about that user. Quote Link to comment Share on other sites More sharing options...
eariass Posted December 2, 2011 Author Share Posted December 2, 2011 I was triyng with this, but I have this error: Fatal error: Call to a member function getUser() on a non-object in /home/mintcom/public_html/apps/arena/camara/hola.php on line 10 Quote Link to comment Share on other sites More sharing options...
Zephni Posted December 2, 2011 Share Posted December 2, 2011 Remember that you used $fb as the class object name before, so if you copy pasted my code it wont work coz i called it $facebook ? Quote Link to comment Share on other sites More sharing options...
eariass Posted December 2, 2011 Author Share Posted December 2, 2011 Thank you Zephni, this is my code: $app_id = "xxxxxxxxxxxx"; $app_secret = "xxxxxxxxxxxxxxxxx"; include_once 'facebook.php'; global $api_id,$app_secret; $facebook=new facebook($api_id,$app_secret); $uid = $facebook->getUser(); echo $uid; but this error are in error_log: [02-Dec-2011 15:20:11] PHP Fatal error: Call to a member function getUser() on a non-object in /home/mintcom/public_html/apps/arena/camara/hola.php on line 10 this is my link http://mint.com.sv/apps/arena/camara/hola.php I dont know what are doing wrong... Quote Link to comment Share on other sites More sharing options...
Zephni Posted December 2, 2011 Share Posted December 2, 2011 require_once("facebook.php"); $config = array(); $config[‘appId’] = 'YOUR_APP_ID'; $config[‘secret’] = 'YOUR_APP_SECRET'; $facebook = new Facebook($config); Try this for setting up the facebook object (Capital 'F'), not even sure if that will make any difference, I havent used the facebook API for a couple of months. Quote Link to comment Share on other sites More sharing options...
eariass Posted December 2, 2011 Author Share Posted December 2, 2011 My idea is create someting like http://www.facebook.com/PepsiIndia, where tha fanpage say hey... xxxxxx without make like. How can do that? Quote Link to comment 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.