Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', '1');
- //MySQL Connection
- mysql_connect("localhost", "***", "****") or
- die("Could not connect: " . mysql_error());
- mysql_select_db("wordpress");
- //Get API POST Action
- $action = '';
- if(isset($_POST['action']))
- {
- $action = $_POST['action'];
- }
- //Execute Action
- switch ($action)
- {
- case 'getEvents':
- getEvents();
- break;
- default:
- echo "{failure:true}";
- break;
- }
- function getEvents()
- {
- //Build Query
- $query = "SELECT id AS event_id, title AS event_title, start AS date FROM wp_aec_event";
- //Execute
- $result = mysql_query($query);
- while($rec = mysql_fetch_array($result))
- {
- $arr[] = $rec;
- }
- //JSON Convert
- $jsonresult = json_encode($arr);
- //Print Result
- echo '{"success":"true","results":'.$jsonresult.'}';
- }
Add Comment
Please, Sign In to add comment