-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemailsubscribers-http-api.php
More file actions
40 lines (32 loc) · 1.19 KB
/
emailsubscribers-http-api.php
File metadata and controls
40 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/*
Plugin Name: EmailSubscribers HTTP API
Plugin URI: https://github.com/hiorgserver/emailsubscribers-http-api
Description: HTTP-API, um neue Abonnenten zu Email Subscribers hinzuzufügen
Version: 0.1
Author: HiOrg Server GmbH
Author URI: http://www.hiorg-server.de
License: GPL
*/
add_action('init', 'emailsubscribers_http_api_init');
function emailsubscribers_http_api_init() {
add_shortcode("http2emailsubscribers","process_http2emailsubscribers");
}
function h2es_error($message) {
echo json_encode(['status' => 'ERROR', 'message' => $message]);
exit;
}
function process_http2emailsubscribers($atts) {
extract(shortcode_atts(array("secret" => ""), $atts));
if (!empty($secret) && ($_REQUEST["secret"]!=$secret)) {
h2es_error('invalid secret');
}
if ('subscribe' !== $_REQUEST['ig_es_external_action']) {
h2es_error('POST-Parameter `ig_es_external_action` does not equals `subscribe`');
}
$handler = new ES_Handle_Subscription();
// constructor fuehrt direkt aus: ->handle_external_subscription();
// dies gibt eine JSON-Response zurück
// und bricht die Verarbeitung ab.
h2es_error('POST-Parameter `list` must contain existent list-hash');
}