You can find example snippets for various languages below. Be sure to update the API key and event id values in the examples.
curl -X POST https://api.heartpingr.maplerope.com/ \
-H "x-api-key: YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{"action":"heartbeat","eventId":"your_event_id","sum":{"your_attribute_name":123}}'
import requests
url = "https://api.heartpingr.maplerope.com/"
headers = {
"x-api-key": "YOUR_KEY_HERE",
"Content-Type": "application/json"
}
data = {
"action": "heartbeat",
"eventId": "your_event_id",
"sum": { "your_attribute_name": 123 }
}
response = requests.post(url, headers=headers, json=data)
print(response.text)
// Node.js native https
const https = require("https");
const data = JSON.stringify({
action: "heartbeat",
eventId: "your_event_id",
sum: { "your_attribute_name": 123 }
});
const options = {
hostname: "api.heartpingr.maplerope.com",
path: "/",
method: "POST",
headers: {
"x-api-key": "YOUR_KEY_HERE",
"Content-Type": "application/json",
"Content-Length": data.length
}
};
const req = https.request(options, (res) => {
res.on("data", (d) => {
process.stdout.write(d);
});
});
req.write(data);
req.end();
<?php
$ch = curl_init("https://api.heartpingr.maplerope.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"action" => "heartbeat",
"eventId" => "your_event_id",
"sum" => [ "your_attribute_name" => 123 ]
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"x-api-key: YOUR_KEY_HERE",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import java.io.*;
import java.net.*;
public class HeartPing {
public static void main(String[] args) throws Exception {
URL url = new URL("https://api.heartpingr.maplerope.com/");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("x-api-key", "YOUR_KEY_HERE");
con.setRequestProperty("Content-Type", "application/json");
con.setDoOutput(true);
String jsonInput = "{\"action\":\"heartbeat\",\"eventId\":\"your_event_id\",\"sum\":{\"your_attribute_name\":123}}";
try (OutputStream os = con.getOutputStream()) {
byte[] input = jsonInput.getBytes("utf-8");
os.write(input, 0, input.length);
}
try (BufferedReader br = new BufferedReader(
new InputStreamReader(con.getInputStream(), "utf-8"))) {
String responseLine;
while ((responseLine = br.readLine()) != null) {
System.out.println(responseLine.trim());
}
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program {
static async Task Main() {
var client = new HttpClient();
var content = new StringContent(
"{\"action\":\"heartbeat\",\"eventId\":\"your_event_id\",\"sum\":{\"your_attribute_name\":123}}",
Encoding.UTF8, "application/json");
content.Headers.Add("x-api-key", "YOUR_KEY_HERE");
var response = await client.PostAsync("https://api.heartpingr.maplerope.com/", content);
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
jsonStr := []byte(`{"action":"heartbeat","eventId":"your_event_id","sum":{"your_attribute_name":123}}`)
req, _ := http.NewRequest("POST", "https://api.heartpingr.maplerope.com/", bytes.NewBuffer(jsonStr))
req.Header.Set("x-api-key", "YOUR_KEY_HERE")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
require "net/http"
require "uri"
require "json"
uri = URI.parse("https://api.heartpingr.maplerope.com/")
request = Net::HTTP::Post.new(uri)
request["x-api-key"] = "YOUR_KEY_HERE"
request["Content-Type"] = "application/json"
request.body = { action: "heartbeat", eventId: "your_event_id", sum: { "your_attribute_name": 123 } }.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
puts response.body
$headers = @{
"x-api-key" = "YOUR_KEY_HERE"
"Content-Type" = "application/json"
}
$body = '{"action":"heartbeat","eventId":"your_event_id","sum":{"your_attribute_name":123}}'
Invoke-RestMethod -Uri "https://api.heartpingr.maplerope.com/" -Method Post -Headers $headers -Body $body
import Foundation
let url = URL(string: "https://api.heartpingr.maplerope.com/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("YOUR_KEY_HERE", forHTTPHeaderField: "x-api-key")
let json = ["action": "heartbeat", "eventId": "your_event_id", "sum": ["your_attribute_name": 123]]
request.httpBody = try? JSONSerialization.data(withJSONObject: json)
URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8)!)
}
}.resume()