Push
var client = new RestClient("https://api.messageflow.com/v2.1/push");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "REPLACE_KEY_VALUE");
request.AddParameter("application/json", "{\"applications\":[\"XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\"],\"to\":[{\"receiver\":\"example-device-id\",\"externalId\":\"xxx-xxx-xxx-xxx\",\"type\":1}],\"title\":{\"pl\":\"test\",\"en\":\"test\"},\"body\":{\"pl\":\"test\",\"en\":\"test\"},\"defaultLanguage\":\"pl\",\"image\":\"http://absolute.url/to/image\",\"silent\":false,\"sound\":\"sound-file.wav\",\"scheduleTime\":\"2020-01-01 12:12:12\",\"ttl\":1540377351,\"externalData\":{\"test\":\"x\",\"test1\":false},\"advanced\":{\"subtitle\":\"subtitle-only-ios\",\"lockscreenVisibility\":1,\"icon\":{\"small\":\"/relative-icon-file-path\",\"large\":\"/relative-icon-file-path\"}},\"action\":{\"url\":\"http://absolute.url/to/redirect/on/click\",\"type\":2},\"actionButtons\":[{\"button\":1,\"icon\":\"my_icon.png\",\"action\":{\"url\":\"www.google.pl\",\"type\":1}}]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.messageflow.com/v2.1/push"
payload := strings.NewReader("{\"applications\":[\"XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\"],\"to\":[{\"receiver\":\"example-device-id\",\"externalId\":\"xxx-xxx-xxx-xxx\",\"type\":1}],\"title\":{\"pl\":\"test\",\"en\":\"test\"},\"body\":{\"pl\":\"test\",\"en\":\"test\"},\"defaultLanguage\":\"pl\",\"image\":\"http://absolute.url/to/image\",\"silent\":false,\"sound\":\"sound-file.wav\",\"scheduleTime\":\"2020-01-01 12:12:12\",\"ttl\":1540377351,\"externalData\":{\"test\":\"x\",\"test1\":false},\"advanced\":{\"subtitle\":\"subtitle-only-ios\",\"lockscreenVisibility\":1,\"icon\":{\"small\":\"/relative-icon-file-path\",\"large\":\"/relative-icon-file-path\"}},\"action\":{\"url\":\"http://absolute.url/to/redirect/on/click\",\"type\":2},\"actionButtons\":[{\"button\":1,\"icon\":\"my_icon.png\",\"action\":{\"url\":\"www.google.pl\",\"type\":1}}]}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "REPLACE_KEY_VALUE")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api.messageflow.com/v2.1/push")
.header("content-type", "application/json")
.header("authorization", "REPLACE_KEY_VALUE")
.body("{\"applications\":[\"XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\"],\"to\":[{\"receiver\":\"example-device-id\",\"externalId\":\"xxx-xxx-xxx-xxx\",\"type\":1}],\"title\":{\"pl\":\"test\",\"en\":\"test\"},\"body\":{\"pl\":\"test\",\"en\":\"test\"},\"defaultLanguage\":\"pl\",\"image\":\"http://absolute.url/to/image\",\"silent\":false,\"sound\":\"sound-file.wav\",\"scheduleTime\":\"2020-01-01 12:12:12\",\"ttl\":1540377351,\"externalData\":{\"test\":\"x\",\"test1\":false},\"advanced\":{\"subtitle\":\"subtitle-only-ios\",\"lockscreenVisibility\":1,\"icon\":{\"small\":\"/relative-icon-file-path\",\"large\":\"/relative-icon-file-path\"}},\"action\":{\"url\":\"http://absolute.url/to/redirect/on/click\",\"type\":2},\"actionButtons\":[{\"button\":1,\"icon\":\"my_icon.png\",\"action\":{\"url\":\"www.google.pl\",\"type\":1}}]}")
.asString();
var request = require("request");
var options = {
method: 'POST',
url: 'https://api.messageflow.com/v2.1/push',
headers: {'content-type': 'application/json', authorization: 'REPLACE_KEY_VALUE'},
body: {
applications: ['XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'],
to: [{receiver: 'example-device-id', externalId: 'xxx-xxx-xxx-xxx', type: 1}],
title: {pl: 'test', en: 'test'},
body: {pl: 'test', en: 'test'},
defaultLanguage: 'pl',
image: 'http://absolute.url/to/image',
silent: false,
sound: 'sound-file.wav',
scheduleTime: '2020-01-01 12:12:12',
ttl: 1540377351,
externalData: {test: 'x', test1: false},
advanced: {
subtitle: 'subtitle-only-ios',
lockscreenVisibility: 1,
icon: {small: '/relative-icon-file-path', large: '/relative-icon-file-path'}
},
action: {url: 'http://absolute.url/to/redirect/on/click', type: 2},
actionButtons: [{button: 1, icon: 'my_icon.png', action: {url: 'www.google.pl', type: 1}}]
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.messageflow.com/v2.1/push",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"applications\":[\"XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\"],\"to\":[{\"receiver\":\"example-device-id\",\"externalId\":\"xxx-xxx-xxx-xxx\",\"type\":1}],\"title\":{\"pl\":\"test\",\"en\":\"test\"},\"body\":{\"pl\":\"test\",\"en\":\"test\"},\"defaultLanguage\":\"pl\",\"image\":\"http://absolute.url/to/image\",\"silent\":false,\"sound\":\"sound-file.wav\",\"scheduleTime\":\"2020-01-01 12:12:12\",\"ttl\":1540377351,\"externalData\":{\"test\":\"x\",\"test1\":false},\"advanced\":{\"subtitle\":\"subtitle-only-ios\",\"lockscreenVisibility\":1,\"icon\":{\"small\":\"/relative-icon-file-path\",\"large\":\"/relative-icon-file-path\"}},\"action\":{\"url\":\"http://absolute.url/to/redirect/on/click\",\"type\":2},\"actionButtons\":[{\"button\":1,\"icon\":\"my_icon.png\",\"action\":{\"url\":\"www.google.pl\",\"type\":1}}]}",
CURLOPT_HTTPHEADER => array(
"authorization: REPLACE_KEY_VALUE",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests
url = "https://api.messageflow.com/v2.1/push"
payload = "{\"applications\":[\"XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\"],\"to\":[{\"receiver\":\"example-device-id\",\"externalId\":\"xxx-xxx-xxx-xxx\",\"type\":1}],\"title\":{\"pl\":\"test\",\"en\":\"test\"},\"body\":{\"pl\":\"test\",\"en\":\"test\"},\"defaultLanguage\":\"pl\",\"image\":\"http://absolute.url/to/image\",\"silent\":false,\"sound\":\"sound-file.wav\",\"scheduleTime\":\"2020-01-01 12:12:12\",\"ttl\":1540377351,\"externalData\":{\"test\":\"x\",\"test1\":false},\"advanced\":{\"subtitle\":\"subtitle-only-ios\",\"lockscreenVisibility\":1,\"icon\":{\"small\":\"/relative-icon-file-path\",\"large\":\"/relative-icon-file-path\"}},\"action\":{\"url\":\"http://absolute.url/to/redirect/on/click\",\"type\":2},\"actionButtons\":[{\"button\":1,\"icon\":\"my_icon.png\",\"action\":{\"url\":\"www.google.pl\",\"type\":1}}]}"
headers = {
'content-type': "application/json",
'authorization': "REPLACE_KEY_VALUE"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.messageflow.com/v2.1/push")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'REPLACE_KEY_VALUE'
request.body = "{\"applications\":[\"XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\"],\"to\":[{\"receiver\":\"example-device-id\",\"externalId\":\"xxx-xxx-xxx-xxx\",\"type\":1}],\"title\":{\"pl\":\"test\",\"en\":\"test\"},\"body\":{\"pl\":\"test\",\"en\":\"test\"},\"defaultLanguage\":\"pl\",\"image\":\"http://absolute.url/to/image\",\"silent\":false,\"sound\":\"sound-file.wav\",\"scheduleTime\":\"2020-01-01 12:12:12\",\"ttl\":1540377351,\"externalData\":{\"test\":\"x\",\"test1\":false},\"advanced\":{\"subtitle\":\"subtitle-only-ios\",\"lockscreenVisibility\":1,\"icon\":{\"small\":\"/relative-icon-file-path\",\"large\":\"/relative-icon-file-path\"}},\"action\":{\"url\":\"http://absolute.url/to/redirect/on/click\",\"type\":2},\"actionButtons\":[{\"button\":1,\"icon\":\"my_icon.png\",\"action\":{\"url\":\"www.google.pl\",\"type\":1}}]}"
response = http.request(request)
puts response.read_body
echo '{"applications":["XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"],"to":[{"receiver":"example-device-id","externalId":"xxx-xxx-xxx-xxx","type":1}],"title":{"pl":"test","en":"test"},"body":{"pl":"test","en":"test"},"defaultLanguage":"pl","image":"http://absolute.url/to/image","silent":false,"sound":"sound-file.wav","scheduleTime":"2020-01-01 12:12:12","ttl":1540377351,"externalData":{"test":"x","test1":false},"advanced":{"subtitle":"subtitle-only-ios","lockscreenVisibility":1,"icon":{"small":"/relative-icon-file-path","large":"/relative-icon-file-path"}},"action":{"url":"http://absolute.url/to/redirect/on/click","type":2},"actionButtons":[{"button":1,"icon":"my_icon.png","action":{"url":"www.google.pl","type":1}}]}' | \
http POST https://api.messageflow.com/v2.1/push \
authorization:REPLACE_KEY_VALUE \
content-type:application/jsonction":{"url":"www.google.pl","type":1}}]}'
Last updated