{"id":2836,"date":"2014-02-23T08:16:06","date_gmt":"2014-02-23T08:16:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/23\/codeigniter-tank_auth_social-facebook-login-throwing-exception-collection-of-common-programming-errors\/"},"modified":"2014-02-23T08:16:06","modified_gmt":"2014-02-23T08:16:06","slug":"codeigniter-tank_auth_social-facebook-login-throwing-exception-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/02\/23\/codeigniter-tank_auth_social-facebook-login-throwing-exception-collection-of-common-programming-errors\/","title":{"rendered":"Codeigniter Tank_Auth_Social Facebook Login Throwing Exception-Collection of common programming errors"},"content":{"rendered":"<p>Sorry If there is a post like this question, I checked but I couldn&#8217;t find any..<\/p>\n<p>I&#8217;m using <code>tank_auth_social<\/code> for Facebook login.<\/p>\n<p>https:\/\/github.com\/sicsol\/Tank-Auth-Social<\/p>\n<p>Also someone mentioned this problem on issues but no reply..<\/p>\n<p>https:\/\/github.com\/sicsol\/Tank-Auth-Social\/issues\/2<\/p>\n<p>After user giving access from Facebook at first login it throws exception like this.<\/p>\n<p>Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in \/home\/hayvanse\/public_html\/application\/libraries\/facebook\/base_facebook.php on line 1058<\/p>\n<p>Yeah so we couldn&#8217;t have write token it means that yeah? But when I click to login and it works. The first one only gives exception due to one problem and its not about Facebook token I think.<\/p>\n<p>I&#8217;m really newbie on Facebook connect stuff, I updated Facebook and <code>base_facebook<\/code> library but didn&#8217;t work.<\/p>\n<p>I hope had this problem and could help me. This is based function on this line so I wonder if I just skip exception,I&#8217;m really confused and looked for it all night \ud83d\ude41<\/p>\n<pre><code>protected function throwAPIException($result) {\n$e = new FacebookApiException($result);\nswitch ($e-&gt;getType()) {\n  \/\/ OAuth 2.0 Draft 00 style\n  case 'OAuthException':\n    \/\/ OAuth 2.0 Draft 10 style\n  case 'invalid_token':\n    \/\/ REST server errors are just Exceptions\n  case 'Exception':\n    $message = $e-&gt;getMessage();\n  if ((strpos($message, 'Error validating access token') !== false) ||\n      (strpos($message, 'Invalid OAuth access token') !== false)) {\n    $this-&gt;setAccessToken(null);\n    $this-&gt;user = 0;\n    $this-&gt;clearAllPersistentData();\n  }\n}\n\nthrow $e;\n}\n<\/code><\/pre>\n<ol>\n<li>\n<p>Please update base_book with this function , check the link please. Main problem was getuser was returnin 0. You have to update code like blow on base_Facebook file.(latest sdk)<\/p>\n<pre><code>protected function getCode() {\n$server_info = array_merge($_GET, $_POST, $_COOKIE);\n\nif (isset($server_info['code'])) {\n    if ($this-&gt;state !== null &amp;&amp;\n            isset($server_info['state']) &amp;&amp;\n            $this-&gt;state === $server_info['state']) {\n\n        \/\/ CSRF state has done its job, so clear it\n        $this-&gt;state = null;\n        $this-&gt;clearPersistentData('state');\n        return $server_info['code'];\n    } else {\n        self::errorLog('CSRF state token does not match one provided.');\n        return false;\n    }\n}\n\nreturn false;\n\n}\n<\/code><\/pre>\n<p>When using CodeIgniter + Facebook PHP SDK: getUser() always returns 0<\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Sorry If there is a post like this question, I checked but I couldn&#8217;t find any.. I&#8217;m using tank_auth_social for Facebook login. https:\/\/github.com\/sicsol\/Tank-Auth-Social Also someone mentioned this problem on issues but no reply.. https:\/\/github.com\/sicsol\/Tank-Auth-Social\/issues\/2 After user giving access from Facebook at first login it throws exception like this. Fatal error: Uncaught OAuthException: An active access [&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-2836","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2836","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=2836"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2836\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}