$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)
{
    $response = array();
示例#2
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']);
$JWT = new JWT();
try {
    $decoded_token = $JWT->decode($header, $key, array($alg));
    if ($data->location === 'insert_video') {
        insertVideo($data, $db);
    } elseif ($data->location === 'fetch_videos') {
        fetchVideos($data, $db);
    } elseif ($data->location === 'delete_video') {
        deleteVideo($data, $db);
    }
} catch (DomainException $e) {
    header_status(401);
    $response['status'] = 'Error';
    $response['message'] = $e->getMessage();
    echo json_encode($response);
    die;
}
function insertVideo($data, $db)
{
    $response = array();
    try {
        $videoTitle = file_get_contents("https://noembed.com/embed?url=https://www.youtube.com/watch?v={$data->video_id}");