{"id":6804,"date":"2014-04-23T08:07:22","date_gmt":"2014-04-23T08:07:22","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/fatal-error-uncaught-oauthexception-error-validating-access-token-collection-of-common-programming-errors\/"},"modified":"2014-04-23T08:07:22","modified_gmt":"2014-04-23T08:07:22","slug":"fatal-error-uncaught-oauthexception-error-validating-access-token-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/fatal-error-uncaught-oauthexception-error-validating-access-token-collection-of-common-programming-errors\/","title":{"rendered":"Fatal error: Uncaught OAuthException: Error validating access token-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/234819a05a20fee4655501bc00ae972f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMarek Kosocki<\/p>\n<pre><code>require ('facebook.php');\n\ndefine('FACEBOOK_APP_ID',\"My_ID\");\ndefine('FACEBOOK_SECRET',\"My_Secret\");\ndefine('REDIRECT_URI',\"My_Website\");\ndefine('PERMISSIONS_REQUIRED', \"publish_stream\");\n$facebook = new Facebook(array(\n    'appId' =&gt; FACEBOOK_APP_ID,\n    'secret' =&gt; FACEBOOK_SECRET,\n    'cookie' =&gt; true\n));\n    $access_token = $facebook-&gt;getAccessToken();\n\n    $query = mysql_query(\"SELECT `title` FROM `tentego_img` WHERE `id` = \".intval($_GET['id']).\"\");\n    $r = mysql_fetch_array($query);\n    $link = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];\n\n    $facebook-&gt;api('\/me\/feed', 'POST',\n                                    array(\n                                      'link' =&gt; $link,\n                                      'message' =&gt; $r[0]\n                                 ));\n<\/code><\/pre>\n<p>Error: Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user.<\/p>\n<p>Please help.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f79c88ffe2a7a3369f6c8ebe826e34f2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSmita<\/p>\n<p>try <code>getAccessTokenFromCode($_GET['code'],REDIRECT_URI)<\/code> instead, it should work. it works for me. your modified code:<\/p>\n<pre><code>require ('facebook.php');\n\ndefine('FACEBOOK_APP_ID',\"My_ID\");\ndefine('FACEBOOK_SECRET',\"My_Secret\");\ndefine('REDIRECT_URI',\"My_Website\");\ndefine('PERMISSIONS_REQUIRED', \"publish_stream\");\n$facebook = new Facebook(array(\n    'appId' =&gt; FACEBOOK_APP_ID,\n    'secret' =&gt; FACEBOOK_SECRET,\n    'cookie' =&gt; true\n));\nif(isset($_GET['code']))\n{\n    $access_token = $facebook-&gt;getAccessTokenFromCode($_GET['code'],REDIRECT_URI);\n     $facebook-&gt;setAccessToken($access_token);\n    $query = mysql_query(\"SELECT `title` FROM `tentego_img` WHERE `id` = \".intval($_GET['id']).\"\");\n    $r = mysql_fetch_array($query);\n    $link = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];\n\n    $facebook-&gt;api('\/me\/feed', 'POST',\n                                    array(\n                                      'link' =&gt; $link,\n                                      'message' =&gt; $r[0]\n                                 ));\n}else\n{\n    $login_url = $facebook-&gt;getLoginUrl($params =array('redirect_uri'=&gt;REDIRECT_URI,'scope' =&gt; PERMISSIONS_REQUIRED));\n echo (\" top.location.href='\".$login_url.\"'\");\n}\n<\/code><\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Marek Kosocki require (&#8216;facebook.php&#8217;); define(&#8216;FACEBOOK_APP_ID&#8217;,&#8221;My_ID&#8221;); define(&#8216;FACEBOOK_SECRET&#8217;,&#8221;My_Secret&#8221;); define(&#8216;REDIRECT_URI&#8217;,&#8221;My_Website&#8221;); define(&#8216;PERMISSIONS_REQUIRED&#8217;, &#8220;publish_stream&#8221;); $facebook = new Facebook(array( &#8216;appId&#8217; =&gt; FACEBOOK_APP_ID, &#8216;secret&#8217; =&gt; FACEBOOK_SECRET, &#8216;cookie&#8217; =&gt; true )); $access_token = $facebook-&gt;getAccessToken(); $query = mysql_query(&#8220;SELECT `title` FROM `tentego_img` WHERE `id` = &#8220;.intval($_GET[&#8216;id&#8217;]).&#8221;&#8221;); $r = mysql_fetch_array($query); $link = $_SERVER[&#8216;SERVER_NAME&#8217;].$_SERVER[&#8216;REQUEST_URI&#8217;]; $facebook-&gt;api(&#8216;\/me\/feed&#8217;, &#8216;POST&#8217;, array( &#8216;link&#8217; =&gt; $link, &#8216;message&#8217; =&gt; $r[0] )); Error: Fatal error: [&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-6804","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6804","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=6804"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6804\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}