Exemplo n.º 1
0
    $response['status'] = 'Error';
    $response['message'] = $e->getMessage();
    echo json_encode($response);
    die;
}
$json = file_get_contents('php://input');
$data = json_decode($json);
$headers = apache_request_headers();
$header = str_replace("Bearer ", "", $headers['Authorization']);
$contentHeaders = explode(';', $headers['Content-Type'], 2);
$JWT = new JWT();
try {
    $decoded_token = $JWT->decode($header, $key, array($alg));
    if ($contentHeaders[0] != 'multipart/form-data') {
        if ($data->location === 'fetch_photos') {
            fetchPhotos($data, $db);
        } elseif ($data->location === 'update_caption') {
            updateCaption($data, $db);
        } elseif ($data->location === 'delete_photo') {
            deletePhoto($data, $db);
        }
    } elseif ($contentHeaders[0] == 'multipart/form-data') {
        $data = json_decode($_POST['data']);
        if ($data->location === 'insert_photos') {
            insertPhotos($data, $db);
        }
    }
} catch (DomainException $e) {
    header_status(401);
    $response['status'] = 'Error';
    $response['message'] = $e->getMessage();
Exemplo n.º 2
0
    include 'HttpFunction.php';
    $memcache_array['memcache'] = new Memcache();
    $memcache_array['cacheAvailable'] = $memcache_array['memcache']->connect($HOST, $MEMCACHED_PORT);
    $memcache_array['MEMCACHE_TTL'] = $MEMCACHE_TTL;
} catch (Exception $e) {
    header_status(500);
    $response['status'] = 'Error';
    $response['message'] = $e->getMessage();
    echo json_encode($response);
    die;
}
$json = file_get_contents('php://input');
$data = json_decode($json);
try {
    if ($data->location == 'fetch_photos') {
        fetchPhotos($data, $db, $memcache_array);
    } elseif ($data->location == 'fetch_videos') {
        fetchVideos($data, $db, $memcache_array);
    } elseif ($data->location == 'fetch_testimonials') {
        fetchTestimonials($data, $db, $memcache_array);
    } elseif ($data->location == 'send_mail') {
        sendMail($data, $gCaptchaSecretKey, $SendGrid_API_KEY);
    }
} catch (Exception $e) {
    header_status(503);
    $response['status'] = 'Error';
    $response['message'] = $e->getMessage();
    echo json_encode($response);
    die;
}
function fetchPhotos($data, $db, $memcache_array)