Di seguito trovate un elenco di esempi utili per la gestione del codice PHP.
Iscrizione di un semplice contatto
$data = array( "options" => array("iddatabase" => "myIdDatabase"), "values" => array("email" => "name@domain.com") ); $data_string = json_encode($data); $access_token = "My_Access_Token"; //see OAuth 2 section. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://ws-mn1.mag-news.it/ws/rest/api/v19/contacts/subscribe'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $headers = array("Content-Type: application/json", "Authorization: Bearer $access_token"); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); print_r($result);
Disiscrizione di un semplice contatto
$data = array( "options" => array("iddatabase" => "myIdDatabase"), "values" => array("email" => "name@domain.com") ); $data_string = json_encode($data); $access_token = "My_Access_Token"; //see OAuth 2 section. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://ws-mn1.mag-news.it/ws/rest/api/v19/contacts/unsubscribe'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $headers = array("Content-Type: application/json", "Authorization: Bearer $access_token"); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); print_r($result)