I am trying to get facebook userid of the users currently logged in. I used this below piece of code ang got error \"Uncaught OAuthException: An active access token must be used
You should use recent PHP-SDK and read documentation which shows exactly how to authenticate the user and get his details.
Exact answer you need already present in PHP-SDK examples
You may also refer to question Get ID from Facebook PHP SDK which have answer to your question too.