Take the 2-minute tour ×

I'm writing a code that allows users to place a like box on their page, so I need to make sure that the page is valid for a like box as personal pages won't work. I'm currently using the facebook.php file, but when I use the following code:

// $fbexist is the page username in this case "clubcoreme"
function CheckFB($fbexist) {  

        $config = array();
        $config['appId'] = 'APP_ID';
        $config['secret'] = 'APP_SECRET';

        $facebook = new Facebook($config);

        try {
            if (!$facebook->api($fbexist)) {
                $personal = "No";
            } else {
                $personal = "Yes";

        } catch(FacebookApiException $e) {
            $checked = array(false, $personal);
            return $checked;
            $checked = array(true, $personal);
            return $checked;

it always comes back as $personal = "No" which should mean that it isn't valid for a like box. But I know for a fact that I can use clubcoreme for a like box. And when I try "JohnnieWalkerLebanon" instead of clubcoreme it works. What am I doing wrong? and is there a better way to do it?

Thank you in advance,


share|improve this question
What do you mean by a valid or invalid page. Does it mean that its a fan page rather than user page. I get the feeling that anything that you place as the value of $personal initially, thats the one going to be returned. Change the personal=no to personal=yes and see what ever is the output. Then that would indicate issues with your loop. –  pal4life Aug 6 '12 at 19:58
Well, if you try to create a "like box" for a personal page like my page R.Y.Haddad the like box will have an error, but when you use the two I specified they both work, but in the script, I get an error that says that clubcoreme won't work when really it will, and no error on JohnnieWalkerLebanon. I tried what you told me switching the yes and no in $personal, and all it did was switch, now my Personal page R.Y.Haddad works and so does clubcoreme, but JohnnieWalkerLebanon does not. What I really need is a way to validate that a page specified by the user will work for a like box. Thank you –  RobertH Aug 7 '12 at 21:14

Your Answer



Browse other questions tagged or ask your own question.