{"id":6395,"date":"2014-04-17T02:00:11","date_gmt":"2014-04-17T02:00:11","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/17\/facebook-uncaught-oauthexception-an-active-access-token-must-be-used-to-query-information-about-the-current-user-collection-of-common-programming-errors-2\/"},"modified":"2014-04-17T02:00:11","modified_gmt":"2014-04-17T02:00:11","slug":"facebook-uncaught-oauthexception-an-active-access-token-must-be-used-to-query-information-about-the-current-user-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/17\/facebook-uncaught-oauthexception-an-active-access-token-must-be-used-to-query-information-about-the-current-user-collection-of-common-programming-errors-2\/","title":{"rendered":"facebook Uncaught OAuthException: An active access token must be used to query information about the current user-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;ve been struggling to find out what is happening with this. My scripts were working fine for a bit and suddenly half stopped.<\/p>\n<p>I&#8217;m accessing the api and am getting back an access token. With the access token, I can access a users public info just fine. However, when I try to post info to their FB account I get this error.<\/p>\n<pre><code>Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. \n<\/code><\/pre>\n<p>Any idea what is happening here? I&#8217;m also using sessions on my site to keep track of internal user ids. Not sure if my sessions could be causing a problem.<\/p>\n<p>This is my upload script where I&#8217;m getting an error.<\/p>\n<pre><code>require 'facebook\/src\/facebook.php';\n\n\n\/\/ Create our Application instance (replace this with your appId and secret).\n$facebook = new Facebook(array(\n  'appId'  =&gt; '12345678',\n  'secret' =&gt; 'REMOVED',\n  'fileUpload' =&gt; true, \n  'cookie' =&gt; true,\n));\n$facebook-&gt;setFileUploadSupport(true); \n\n$me = null;\n\/\/ Session based API call.\nif ($session) {\n  try {\n    $uid = $facebook-&gt;getUser();\n    $me = $facebook-&gt;api('\/me');\n  } catch (FacebookApiException $e) {\n    error_log($e);\n  }\n}\n\n\n\/\/ login or logout url will be needed depending on current user state.\nif ($me) {\n  $logoutUrl = $facebook-&gt;getLogoutUrl();\n} else {\n  $loginUrl = $facebook-&gt;getLoginUrl();\n}\n\n\n$photo_details = array('message' =&gt; 'my place');\n$file='photos\/my.jpg'; \/\/Example image file\n$photo_details['image'] = '@' . realpath($file);\n$upload_photo = $facebook-&gt;api('\/me\/photos', 'post', $photo_details);\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been struggling to find out what is happening with this. My scripts were working fine for a bit and suddenly half stopped. I&#8217;m accessing the api and am getting back an access token. With the access token, I can access a users public info just fine. However, when I try to post info to [&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-6395","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6395","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=6395"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6395\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}