Fixing few bugs I had, and adding try-catch to FB

Bug fixes regarding endTurn php.
Adding try-catch clause to the FB and cordova code, so if it fails, it
will catch it.