Fatal error: Uncaught OAuthException: Error validating access token-Collection of common programming errors
Marek Kosockirequire ('facebook.php'); define('FACEBOOK_APP_ID',"My_ID"); define('FACEBOOK_SECRET',"My_Secret"); define('REDIRECT_URI',"My_Website"); define('PERMISSIONS_REQUIRED', "publish_stream"); $facebook = new Facebook(array( 'appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_SECRET, 'cookie' => true )); $access_token = $facebook->getAccessToken(); $query = mysql_query("SELECT `title` FROM `tentego_img` WHERE `id` = ".intval($_GET['id']).""); $r = mysql_fetch_array($query); $link = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $facebook->api('/me/feed', 'POST', array( 'link' => $link, 'message' => $r[0] ));
Error: Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user.
Please help.
Smitatry
getAccessTokenFromCode($_GET['code'],REDIRECT_URI)
instead, it should work. it works for me. your modified code:require ('facebook.php'); define('FACEBOOK_APP_ID',"My_ID"); define('FACEBOOK_SECRET',"My_Secret"); define('REDIRECT_URI',"My_Website"); define('PERMISSIONS_REQUIRED', "publish_stream"); $facebook = new Facebook(array( 'appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_SECRET, 'cookie' => true )); if(isset($_GET['code'])) { $access_token = $facebook->getAccessTokenFromCode($_GET['code'],REDIRECT_URI); $facebook->setAccessToken($access_token); $query = mysql_query("SELECT `title` FROM `tentego_img` WHERE `id` = ".intval($_GET['id']).""); $r = mysql_fetch_array($query); $link = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $facebook->api('/me/feed', 'POST', array( 'link' => $link, 'message' => $r[0] )); }else { $login_url = $facebook->getLoginUrl($params =array('redirect_uri'=>REDIRECT_URI,'scope' => PERMISSIONS_REQUIRED)); echo (" top.location.href='".$login_url."'"); }