Commencer avec l'API de SimpleMail

Vous avez besoin de deux choses:

  1. Avoir un compte SimpleMail
  2. Demander votre clé API

Examples

All calls to the API are done via HTTPS. The API returns JSON data.

View a simple example using cURL

curl -H 'apikey: YOUR_SIMPLEMAIL_API_KEY' \
	-d 'email=youremail&password=yourpassword' \
	https://api.simple-mail.fr/User/Login
		

View an example using PHP

$data = array(
	'email'     => 'email@address.com',
	'password'  => 'password123'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.simple-mail.fr/User/login'); 
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apikey: YOURAPIKEY'));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);

if ($result === false) {
	unset($result);
	echo 'Curl error: ' . curl_error($ch);
}
    
curl_close($ch);

if (isset($result)) {
	$json_object = json_decode($result, true);

	if ($json_object['status'] == 'success') {
		foreach($json_object['data'] as $key => $value) {
			echo $key . " : " . $value . "\n";
		}
	} else {
		echo $json_object['data'];
	}
}
		

View an example using Ruby

require 'net/http'
require 'net/https'
require 'rubygems'
require 'json'

http = Net::HTTP.new('api.simple-mail.fr', 443)
http.use_ssl = true
path = '/User/login'

data = {
  'email' => 'email@address.com', 
  'password' => 'password123'
}

headers = {
  'apikey' => 'YOURAPIKEY'
}

resp, data = http.post(path, data.to_query, headers)

result = JSON.parse(data)
puts result['data']