{"id":6821,"date":"2014-04-23T08:09:46","date_gmt":"2014-04-23T08:09:46","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/php-fatal-error-call-to-a-member-function-error-when-logging-in-to-facebook-collection-of-common-programming-errors\/"},"modified":"2014-04-23T08:09:46","modified_gmt":"2014-04-23T08:09:46","slug":"php-fatal-error-call-to-a-member-function-error-when-logging-in-to-facebook-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/php-fatal-error-call-to-a-member-function-error-when-logging-in-to-facebook-collection-of-common-programming-errors\/","title":{"rendered":"PHP Fatal error: Call to a member function error when logging in to Facebook-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;ve been working on this for 5 hours now, looking up every single stackoverflow and google search item I know but I couldn&#8217;t get this solved. I was wondering if I could turn to you guys for help.<\/p>\n<p>I&#8217;m creating this WordPress widget that allows users to log onto facebook to listen to my school&#8217;s campus radio.<\/p>\n<p>I&#8217;ve done the usual (I think correct) steps such as follows:<\/p>\n<pre><code>    require_once('facebook.php');\n\n    $facebook = new Facebook(array(\n      'appId'  =&gt; 'my id',\n      'secret' =&gt; 'my secret',\n    ));\n\n    \/\/ Get User ID\n    $user = $facebook-&gt;getUser();\n\n    if ($user) {\n      $logoutUrl = $facebook-&gt;getLogoutUrl();\n    } else {\n      $loginUrl = $facebook-&gt;getLoginUrl();\n    }\n<\/code><\/pre>\n<p>&#8230;And several unimportant lines of code later&#8230;<\/p>\n<pre><code>      window.fbAsyncInit = function() {\n        FB.init({\n          appId: '',\n          cookie: true,\n          xfbml: true,\n          oauth: true\n        });\n        FB.Event.subscribe('auth.login', function(response) {\n          window.location.reload();\n        });\n        FB.Event.subscribe('auth.logout', function(response) {\n          window.location.reload();\n        });\n      };    \n<\/code><\/pre>\n<p>However, I get an error that says &#8220;PHP Fatal error: Call to a member function getAppID() on a non-object in&#8230;&#8221; for the line:<\/p>\n<pre><code>appId: '',\n<\/code><\/pre>\n<p>I&#8217;ve tried other lines like<\/p>\n<pre><code>appId: '',\n<\/code><\/pre>\n<p>and<\/p>\n<pre><code>appId: '',\n<\/code><\/pre>\n<p>and<\/p>\n<pre><code>appId: '',\n<\/code><\/pre>\n<p>All of which didn&#8217;t work. Also, I don&#8217;t know if this is another error but my<\/p>\n<pre><code>$loginUrl\n<\/code><\/pre>\n<p>and<\/p>\n<pre><code>$logoutUrl\n<\/code><\/pre>\n<p>is both null&#8230; :\\<\/p>\n<p>I&#8217;m a php self-taught beginner, this is in fact the first php project I&#8217;m working on. If this problem&#8217;s nowhere on this site I&#8217;m pretty sure it has to be something wrong I did but the problem is I don&#8217;t know what it is.<\/p>\n<p>So yeah, I decided to put it out to you guys. Thank you very much for helping out! \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been working on this for 5 hours now, looking up every single stackoverflow and google search item I know but I couldn&#8217;t get this solved. I was wondering if I could turn to you guys for help. I&#8217;m creating this WordPress widget that allows users to log onto facebook to listen to my school&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6821","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6821"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6821\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}