Altered javascript calls to generate_extended_tokens.php to account for json encoding and removed console debug lines.
Removed call to encode returned tokens as json as they are already json encoded.
Added, removed and edited functions dealing with Facebook to use latest Facebook php SDK 4.0.
Altered check on array key to see if it is set before being accessed.