@@ -6,23 +6,23 @@ |
||
| 6 | 6 | $result = array(); |
| 7 | 7 | // only serve POST request containing valid json data |
| 8 | 8 | if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
|
| 9 | - if (isset($_SERVER['CONTENT_TYPE']) && trim(strtolower($_SERVER['CONTENT_TYPE']) == 'application/json')) {
|
|
| 10 | - // get posted json data |
|
| 11 | - if (($strJSON = trim(file_get_contents('php://input'))) === false) {
|
|
| 12 | - $result['msg'] = 'invalid JSON data!'; |
|
| 13 | - } else {
|
|
| 14 | - $oDP = new PNDataProviderSQLite(); |
|
| 15 | - if ($oDP->saveSubscription($strJSON) !== false) {
|
|
| 16 | - $result['msg'] = 'subscription saved on server!'; |
|
| 17 | - } else {
|
|
| 18 | - $result['msg'] = 'error saving subscription!'; |
|
| 19 | - } |
|
| 20 | - } |
|
| 21 | - } else {
|
|
| 22 | - $result['msg'] = 'invalid content type!'; |
|
| 23 | - } |
|
| 9 | + if (isset($_SERVER['CONTENT_TYPE']) && trim(strtolower($_SERVER['CONTENT_TYPE']) == 'application/json')) {
|
|
| 10 | + // get posted json data |
|
| 11 | + if (($strJSON = trim(file_get_contents('php://input'))) === false) {
|
|
| 12 | + $result['msg'] = 'invalid JSON data!'; |
|
| 13 | + } else {
|
|
| 14 | + $oDP = new PNDataProviderSQLite(); |
|
| 15 | + if ($oDP->saveSubscription($strJSON) !== false) {
|
|
| 16 | + $result['msg'] = 'subscription saved on server!'; |
|
| 17 | + } else {
|
|
| 18 | + $result['msg'] = 'error saving subscription!'; |
|
| 19 | + } |
|
| 20 | + } |
|
| 21 | + } else {
|
|
| 22 | + $result['msg'] = 'invalid content type!'; |
|
| 23 | + } |
|
| 24 | 24 | } else {
|
| 25 | - $result['msg'] = 'no post request!'; |
|
| 25 | + $result['msg'] = 'no post request!'; |
|
| 26 | 26 | } |
| 27 | 27 | // let the service-worker know the result |
| 28 | 28 | echo json_encode($result); |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | $result = array(); |
| 7 | 7 | // only serve POST request containing valid json data |
| 8 | 8 | if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
|
| 9 | - if (isset($_SERVER['CONTENT_TYPE']) && trim(strtolower($_SERVER['CONTENT_TYPE']) == 'application/json')) {
|
|
| 9 | + if (isset($_SERVER['CONTENT_TYPE']) && trim(strtolower($_SERVER['CONTENT_TYPE']) == 'application/json')) {
|
|
| 10 | 10 | // get posted json data |
| 11 | 11 | if (($strJSON = trim(file_get_contents('php://input'))) === false) {
|
| 12 | 12 | $result['msg'] = 'invalid JSON data!'; |