Firebase Notofication Request Various To - php

There is a way to send in a firebase notidication request, various to
header:
Content-Type: application/json
Authorization: key=
Body:
{ "data":
{
"title": "Firebase notification",
"detail": "I am firebase notification. you can customise me. enjoy"
},
"to" : "c_ejgKg_0rY:APA91bEtp77PP99UuDvza1gKOKAmfqVg3ZHflWYQUGPQJFCvWy3Ortswv45MjtT8LQaRoebLqSXPTeaO21hm7QVnG694GgVmALbK5LIDAsyohKlTFlQSlwcdYQmPS5GnLGjLwfA3b34z",
"sound":"default"
}
here an example of the request, please help me, thank you

Use registration_ids instead...
Firebase Cloud Messaging HTTP protocol | Firebase
header:
Content-Type: application/json
Authorization: key =
Body:
{
"data":
{
"title": "Firebase notification",
"detail": "I am firebase notification. you can customise me. enjoy"
},
"registration_ids" : [
"c_ejgKg_0rY:APA91bEtp77PP99UuDvza1gKOKAmfqVg3ZHflWYQUGPQJFCvWy3Ortswv45MjtT8LQaRoebLqSXPTeaO21hm7QVnG694GgVmALbK5LIDAsyohKlTFlQSlwcdYQmPS5GnLGjLwfA3b34z"
],
"sound":"default"
}

Related

How can I send push notification from PHP website to iOS and Android?

How I can send push notification from PHP website to iOS devices and Android devices?
Is there any tutorial for that?
You can use several premade services for push notifications like Firebase Messaging, One Signal, etc. For Firebase cloud Messaging Integration with PHP, please visit this Link. After setting up, Just Send this POST request with the user token
POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1
Content-Type: application/json
Authorization: Bearer ya29.ElqKBGN2Ri_Uz...PbJ_uNasm
{
"message": {
"token" : <token of destination app>,
"notification": {
"title": "FCM Message",
"body": "This is a message from FCM"
},
"webpush": {
"headers": {
"Urgency": "high"
},
"notification": {
"body": "This is a message from FCM to web",
"requireInteraction": "true",
"badge": "/badge-icon.png"
}
}
}
}
or Send a Push Notification using topic
https://fcm.googleapis.com//v1/projects/<YOUR-PROJECT-ID>/messages:send
Content-Type: application/json
Authorization: bearer <YOUR-ACCESS-TOKEN>
{
"message": {
"topic": "matchday"
"notification": {
"title": "Background Message Title",
"body": "Background message body"
},
"webpush": {
"fcm_options": {
"link": "https://dummypage.com"
}
}
}
}
For One Signal, Visit this Link for more information. Also, alternatively, you can use web sockets, if you don't want premade services.

Microsoft Graph - POST request error 20132

I can't seem to get a POST request to create assignments using Microsoft Graph.
Both in the Graph Explorer and in PHP I get the same error: "message": "The content of the request is invalid. Common causes are an invalid Content-Type header or no content in the body.",
Endpoint: https://graph.microsoft.com/beta/education/classes/class-id/assignments
Request Headers: content-type: application/json
Body:
{
"dueDateTime": "2014-02-01T00:00:00Z",
"displayName": "Midterm 1",
"instructions": {
"contentType": "Text",
"content": "Read chapters 1 through 3"
},
"grading": {
"#odata.type": "#microsoft.education.assignments.api.educationAssignmentPointsGradeType",
"maxPoints": 100
},
"assignTo": {
"#odata.type": "#microsoft.education.assignments.api.educationAssignmentClassRecipient"
},
"status":"draft",
"allowStudentsToAddResourcesToSubmission": true
}
Any help would be truly appreciated!
Please see image of Graph Explorer below.
Figured it out. Removing the "contentType": "Text" attribute from instructions worked.

POST request through Guzzle php

hi i wanted to make a post request to dropbox.i found there is this guzzle which can be easily send http req using php. here the http code given by dropbox
`POST /2/files/list_folder
Host: https://api.dropboxapi.com
User-Agent: api-explorer-client
Authorization: Bearer <access-token>
Content-Type: application/json
{
"path": "",
"recursive": false,
"include_media_info": true,
"include_deleted": false,
"include_has_explicit_shared_members": false
}`
This is my php code i coded for above request;
$response=$client->request('POST','https://api.dropboxapi.com',
[
'headers'=>[
'Authorization'=>'Bearer '.$API,
'User-Agen'=>'api-explorer-client',
'Content-Type'=>'application/json'
],
'form_params'=>[
'path'=>'',
'recursive'=>'false',
'include_media_info'=> 'true',
'include_deleted'=> 'false',
'include_has_explicit_shared_members'=> 'false'
]
]);
$headers = $response->getHeaders();
$body =$response->getBody();
$print=json_decode($body,true);
//Output headers and body for debugging purposes
var_dump($headers);echo"<br><br>";
var_dump($print);?>
this should give something similar to following ,but i get a small array
{"entries": [
{
".tag": "folder",
"name": "Photos",
"path_lower": "/photos",
"path_display": "/Photos",
"id": "id:bwGPfg_v6ZUAAAAAAAAAOA"
},`
what i missed here?
PS:im new to php related stuff :)
You are sending JSON, not an HTML form. So use 'json' instead of 'form_params'.

POST JSON Object with multiple headers in php

Request header
Content-Type: application/json
Authorization: Bearer [access token]
Accept: application/json
if send unicode string with message, please set Content-Type charset to UTF-8
Following is a sample request of send service.
URL-https://example.com/requests
Method - POST
Body
{
"outboundSMSMessageRequest": {
"address": [
"tel:+94771234567"
],
"senderAddress": "tel:12345678",
"outboundSMSTextMessage": {
"message": "Test Message"
},
"clientCorrelator": "123456",
"receiptRequest": {
"notifyURL": "http://128.199.174.220:1080/sms/report",
"callbackData": "some-data-useful-to-the-requester"
},
"senderName": "ACME Inc."
}
}
How to post and get responce
ajax
headers: {
'X-HTTP-Method-Override': 'POST',
'Content-Type': 'application/json'
},
or vanilla js
How to create javascript POST request to server with Headers and Data

send json request using php for and api

I am working on some api in which I send information using json.
POST /api/v3/users/ HTTP/1.1
Host: example.com
Content-Type: application/vnd.api+json
Authorization: Bearer ab1dcb45be7e43db2212b0d2b0ca3892
This is the information. Using this will get that response but I don't know how to use this in php and not use js?
get response:
{
"users": [ {
"username": "username",
"phone": "06123",
"last_name": "myname",
"address": "some addr",
"newsletter": true,
"dob": "1974-12-31",
"x_id": "123ext",
"email": "user2#mail.nl",
"email_verified": true,
"social" : {
"facebook": { "id": "100000730165158"},
"twitter": {"id": "139029213"},
"linkedin": {"id": "7EA06I71K5"},
"google": {"id": "104763295979778440139"}
}
}]
}
But I don't know how to use this, meaning how to send request.
You can store this content in avariable, and then just json_decode it to convert it into php array.

Categories