Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])) {
- //form's fields name:
- $name = $_POST['nome'];
- $email = $_POST['email'];
- //API url:
- $url = 'https://panel.kloudymail.com/subscriber/create/';
- $data = array(
- 'NOME' => $name,
- 'KM_RECIPIENT' => $email
- //"account_code": "95031C8E-3F59-4842-A7E7-272BA0D7054C",
- //"list_code": "73C926A0-E6FC-4A50-B127-C46C04FB7FF0"
- );
- //sending request (according to prosperworks documentation):
- // use key 'http' even if you send the request to https://...
- $options = array(
- 'http' => array(
- 'header' => "Content-Type: application/json; charset=UTF-8".
- "Authorization: Bearer dea8d0908678147508e89ad7646092dcc6fe1e84",
- 'method' => 'POST',
- 'content' => json_encode($data)
- )
- );
- //engine:
- $context = stream_context_create($options);
- $result = file_get_contents($url, false, $context);
- if ($result === FALSE) { /* Handle error */ }
- //compiling to JSON (as wrote above):
- $resultData = json_decode($result, TRUE);
- //display what was sent:
- //echo '<h2>Sent: </h2>';
- //echo $resultData['published'];
- //dump var:
- //var_dump($result);
- }
- echo '<pre>';
- var_dump($result);
- echo '</pre>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement