diff --git a/classes/APIv1.php b/classes/APIv1.php index 4627a16..e9be530 100644 --- a/classes/APIv1.php +++ b/classes/APIv1.php @@ -11,8 +11,11 @@ class APIv1 extends CustomModule $response_code = 200; $error = 'An unexcepted error has occurred.'; + echo($_SERVER['REQUEST_METHOD']); + print_r($this->request_methods); + // Checks the request method - if ((is_array($this->request_methods) && !in_array($this->request_methods, $_SERVER['REQUEST_METHOD'])) + if ((is_array($this->request_methods) && !in_array($_SERVER['REQUEST_METHOD'], $this->request_methods)) || $this->request_methods != $_SERVER['REQUEST_METHOD']) { $response_code = 400; diff --git a/conf/nginx.conf b/conf/nginx.conf index c575337..493b56a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -42,7 +42,7 @@ server break; } - # Accommodate UID's in the URI + # Accommodate UIDs at the end of the URI rewrite ^/(.+)/(\d+)$ /index.php?request=$1&uid=$2 last; # and the rest diff --git a/modules/api/v1/leaderboard.php b/modules/api/v1/leaderboard.php new file mode 100644 index 0000000..023b673 --- /dev/null +++ b/modules/api/v1/leaderboard.php @@ -0,0 +1,12 @@ + diff --git a/templates/api.phtml b/templates/api.phtml index 7ba8a12..3b3c97a 100644 --- a/templates/api.phtml +++ b/templates/api.phtml @@ -48,28 +48,14 @@ if ($this->module['api_key'])

GET

-

Returns the members, scores and ranks sorted in descending order by score.

+

Returns the members, scores and ranks sorted in descending order by score. {uid} corresponds with the UID of the leaderboards which can be found on the My Leaderboards page.

-

{uid} corresponds with the UID found on the My Leaderboards page.

- -

/leaderboard/{uid}/member/{member}

- -

The value of {member} is a unique indicator you are using in your system. It can be anything you want it to be as long as it’s unique within your system.

- -

We highly recommend using something that won’t change in the future like an auto incremented field from your database.

- -

GET

- -

Returns the score and rank for the {member} specified.

+

Optionally the results can be filtered by member where member is a unique value that maps back to your system. We highly recommend using something that won’t change in the future like an auto incremented field from your database.

POST

-

Allows you set the score of the {member} by passing the {score} parameter.

- -

The required score parameter must be an integer.

+

Allows you set the score of a member by passing the score parameter. The required score parameter must be an integer.

PUT

-

Allows you to increment the score of the specified {member} by 1 point. If the {member} does not exist, the score will be be set to 1 point. If you would like to increase by more than one or decrement the score, include the value parameter.

- -

The optional value parameter must be an integer.

+

Allows you to increment the score of a member by 1 point. If the member does not exist, the score will be be set to 1 point. If you would like to increase by more than one or decrement the score you can include the value parameter. The optional value parameter must be an integer.