https://github.com/droduit/webpush-api
https://github.com/droduit/webpush-api
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/droduit/webpush-api
- Owner: droduit
- Created: 2019-09-01T19:47:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-02T07:32:44.000Z (over 6 years ago)
- Last Synced: 2025-01-02T20:19:05.400Z (over 1 year ago)
- Language: PHP
- Size: 456 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WebPush API
## How to use
```js
const API_URL = "https://dominique.leroduit.com/webpush/api.php";
var bodyObj = {
subscriber: {
endpoint: 'https://fcm.googleapis.com/fcm/send/f62gDWNV8No:APA91bHZ5A0tK9HgSEf7Yj_oGNa85lIKeedzucTkZ4dXY4_1GDQMnG1lEnK46aQviptKWjEZnlnPiyrjnatgsvCM3P3ZbXwzcEfVxewqQrLlBH8T1ZbHIcURinQHuyzGQqYe_uCDNM5c',
authToken: "x2-Wy6YXaGlU5ABWd9YIzA",
publicKey: "BJq90fq61XXV0tle4eL64g07xtmBscYN6fFHQbOk04anGNlwaQDVRTy7HgHuX_jnCEN7BRrkb-LjYqPffQ5Atvs",
},
notification: {
title: "Titre de la notification",
body: "Message de la notification"
}
}
```
### JS
```js
fetch(API_URL, {
method: 'POST',
body: JSON.stringify(bodyObj)
}).then(function(response) {
return response.json();
}).then(function(data) {
console.log(data.status, data.message);
});
```
### JQuery
```js
$.post(API_URL, bodyObj, function(data) {
console.log(data);
});
```