-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
72 lines (61 loc) · 1.74 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Step 1: Require the Slim Framework
*
* If you are not using Composer, you need to require the
* Slim Framework and register its PSR-0 autoloader.
*
* If you are using Composer, you can skip this step.
*/
require 'library/Slim/Slim.php';
\Slim\Slim::registerAutoloader();
/**
* Step 2: Instantiate a Slim application
*
* This example instantiates a Slim application using
* its default settings. However, you will usually configure
* your Slim application now by passing an associative array
* of setting names and values into the application constructor.
*/
$app = new \Slim\Slim();
/**
* Step 3: Define the Slim application routes
*
* Here we define several Slim application routes that apache_response_headers(oid)
* to appropriate HTTP request methods. In this example, the second
* argument for `Slim::get`, `Slim::post`, `Slim::put`, `Slim::patch`, and `Slim::delete`
* is an anonymous function.
*/
// POST route
$app->post(
'/campaigns/:id',
function ( $id ) use ( $app ) {
// global $wpdb;
// $table_campaigns = $wpdb->prefix . 'lf_campaigns';
// // Set Query
// $sql = "SELECT id FROM $table_campaigns WHERE id = $id";
// // Get Results
// $results = $wpdb->get_results( $sql, ARRAY_A );
// // Check if the Campaign Id exists
// if ( count( $results ) > 0 ) {
// $app->status( 200 );
// } // end if
// else {
// $app->status( 500 );
// } // end else
// Check if posts is set
if ( isset( $_REQUEST['posts'] ) ) {
$app->status( 200 );
} // end if
else {
$app->status( 500 );
} // end else
}
);
/**
* Step 4: Run the Slim application
*
* This method should be called last. This executes the Slim application
* and returns the HTTP response to the HTTP client.
*/
$app->run();