Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //// java.php
- <?php
- $response = array();
- header("Content-Type:application/json");
- if($_POST){
- $token = $_POST['token'];
- include 'JWTManager.php';
- $check = CheckToken($token,$key);
- if(isset($check["success"]) && $check["success"] == -1){
- $response["success"] = -1;
- $response["message"] = $check["message"];
- }else{
- $response = $check;
- }
- }
- echo json_encode($response);
- ?>
- //// JWTManager.php
- <?php
- require_once 'vendor/autoload.php';
- use \Firebase\JWT\JWT;
- $key = 'cxrrQXzprE';
- function GenerateToken($token,$key){
- return JWT::encode($token, $key);
- }
- function CheckToken($jwt,$key){
- try{
- $decoded = JWT::decode($jwt,$key,array('HS256'));
- return (array)$decoded;
- }catch(Exception $e){
- $error = array();
- $error["message"] = $e->getMessage();
- $error["success"] = -1;
- return $error;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement