Facebook App Fatal error: Uncaught OAuthException:-Collection of common programming errors

First I authenticate the user and get permissions on index.php and after authenticating the user is redirected to action.php where the app does its work.

I get this error

Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /home/flysw4fr/public_html/event/facebook.php

This app worked fine two years ago and now it no longer works

here is my code for action.php