<?php

	 header('Access-Control-Allow-Origin: *');  
	 header('Content-Type: application/json');

	require_once 'init.php';

	$id = (isset($_GET['id']))?$_GET['id']:'19239192438542183812348328591239123';
	$key = (isset($_GET['key']))?$_GET['key']:'abc';

	$dao = new MobileApp();
	$app = $dao->getById($id);

	if($app->num_rows() === 0) {

		http_response_code(404);
		exit;

	}

	$app = $app->result();

	if(MobileApp::hash($app->id)!=$key) {

		http_response_code(404);
		exit;

	}

	$std = array(
		'tipo' => $app->tipo,
		'http' => array( 'audio' => $app->audio_http, 'video' => $app->video_http ),
		'rtmp' => array( 'audio' => $app->audio_rtmp, 'video' => $app->video_rtmp ),
		'smtp' => array( 'servidor' => $app->smtp_servidor, 'porta' => $app->smtp_porta, 'usuario' => $app->smtp_usuario, 'senha' => $app->smtp_senha ),
		'fanpage' => $app->fanpage,
		'twitter' => $app->twiiter,
		'youtube' => $app->youtube,
		'instagram' => $app->instagram,
		'googleplus' => $app->googleplus,
		'whatsapp' => $app->whatsapp,
		'email' => $app->email
	);

	echo json_encode($std);
