PHP Fatal error: Call to a member function error when logging in to Facebook-Collection of common programming errors

I’ve been working on this for 5 hours now, looking up every single stackoverflow and google search item I know but I couldn’t get this solved. I was wondering if I could turn to you guys for help.

I’m creating this WordPress widget that allows users to log onto facebook to listen to my school’s campus radio.

I’ve done the usual (I think correct) steps such as follows:

    require_once('facebook.php');

    $facebook = new Facebook(array(
      'appId'  => 'my id',
      'secret' => 'my secret',
    ));

    // Get User ID
    $user = $facebook->getUser();

    if ($user) {
      $logoutUrl = $facebook->getLogoutUrl();
    } else {
      $loginUrl = $facebook->getLoginUrl();
    }

…And several unimportant lines of code later…

      window.fbAsyncInit = function() {
        FB.init({
          appId: '',
          cookie: true,
          xfbml: true,
          oauth: true
        });
        FB.Event.subscribe('auth.login', function(response) {
          window.location.reload();
        });
        FB.Event.subscribe('auth.logout', function(response) {
          window.location.reload();
        });
      };    

However, I get an error that says “PHP Fatal error: Call to a member function getAppID() on a non-object in…” for the line:

appId: '',

I’ve tried other lines like

appId: '',

and

appId: '',

and

appId: '',

All of which didn’t work. Also, I don’t know if this is another error but my

$loginUrl

and

$logoutUrl

is both null… :\

I’m a php self-taught beginner, this is in fact the first php project I’m working on. If this problem’s nowhere on this site I’m pretty sure it has to be something wrong I did but the problem is I don’t know what it is.

So yeah, I decided to put it out to you guys. Thank you very much for helping out! 🙂