<?php //header("Content-Type:application/json"); include_once "../base/bd_configuracion.php"; include_once "../base/funcionesBase.php"; include_once "../sharedfunctions/SharedFunctions.php"; include_once "../Tournament.php"; $con = new bd_configuracion(); $con->conectar(); if (isset($_POST['data']) && empty($_POST['data']) == false) { $strTemp = $_POST['data']; try { $stringWinnersArray = tournament(str_replace(' ', '', $strTemp)); setWinnerPoints(getNameWinner($stringWinnersArray)); deliverResponse(200, $stringWinnersArray); } catch (Exception $e) { deliverResponse(400, "Error processing data"); } } else { deliverResponse(400, "Error processing data"); } function deliverResponse($status, $data) { header("HTTP/1.1 {$status}"); $response['status'] = $status; $response['winner'] = str_replace('"', '', $data); $jsonResponse = json_encode($response); echo $jsonResponse; }
if (!is_null($autoreply['text'])) { //we setup the necessary fields for the API call $api_fields = array('from' => '6590249973', 'to' => array($sender), 'text' => $autoreply['text']); $api_result = APISendSMS($api_fields); $json_result = json_decode($api_result, true); //we log the SMS as an outbound message in the database $outbound_data = array('api_ref_id' => $json_result['bulkId'], 'title' => 'Auto-Reply [' . $keyword . ']', 'from' => '6590249973', 'to' => implode(', ', $api_fields['to']), 'text' => $autoreply['text'], 'status' => $json_result['messages'][0]['status']['groupName'], 'credits_used' => $autoreply['num_msg']); //enter details of outbound msg into outbound table and deduct appropriate user credits uploadOutboundInfo($mysqli, $outbound_data); subtractUserCredits($mysqli, $outbound_data['credits_used']); } break; } } //we upload the inbound msg uploadInboundInfo($mysqli, $sender, $msg, $assoc_user); // close connection closeConnection($mysqli); } else { deliverResponse(false); } //We provide 2 possible responses for any requests to this callback URL //no body is returned function deliverResponse($status_ok) { if ($status_ok) { header("HTTP/1.1 200 OK"); } else { header("HTTP/1.1 400 Bad Request"); } }
<?php header("Content-Type:application/json"); include_once "../base/bd_configuracion.php"; include_once "../base/funcionesBase.php"; include_once "../fileFunctions.php"; $con = new bd_configuracion(); $con->conectar(); if (isset($_GET['first']) && isset($_GET['second'])) { // button name $first = trim($_GET['first']); $second = trim($_GET['second']); setWinnerPoints($first); deliverResponse(200, "success"); } else { deliverResponse(200, "error"); } function deliverResponse($status, $statusMessage) { header("HTTP/1.1 {$status} {$statusMessage}"); $response['status'] = $status; $response['status_message'] = $statusMessage; //$response['data'] = $data; $jsonResponse = json_encode($response); echo $jsonResponse; }
<?php header("Content-Type:application/json"); include_once "../base/bd_configuracion.php"; include_once "../base/funcionesBase.php"; $con = new bd_configuracion(); $con->conectar(); $playersCount = 10; if (isset($_GET['count'])) { $playersCount = $_GET['count']; } $queryResult = getTop($playersCount); $nameArray = createArrayNames($queryResult); deliverResponse(200, $nameArray); function deliverResponse($status, $data) { header("HTTP/1.1 {$status}"); $response['status'] = $status; $response['players'] = $data; $jsonResponse = json_encode($response); echo $jsonResponse; } function createArrayNames($queryResult) { $dataString = "["; $i = 1; while ($row = mysql_fetch_array($queryResult, MYSQL_ASSOC)) { $dataString .= $row["win_tour_name"] . ","; $i++; } $dataString .= "]";