Integrated SMS API with PHP

0

I have a visit scheduling form, when the user does their scheduling and confirms an email is triggered for the same with scheduling information. I would like to know if anyone has already integrated an SMS API with PHP.

Example:

My sending API uses the following URL to send SMS

link World

How do I include this API as soon as it triggers the already confirmed email to the user about the schedule.

Part of the data entry form code                 

            <div id="wizard-frame-3" class="wizard-frame" style="display:none;">
                <div class="frame-container">

                    <h3 class="frame-title"><?php echo $this->lang->line('step_three_title'); ?></h3>

                    <div class="frame-content row">
                        <div class="col-xs-12 col-sm-6">
                            <div class="form-group">
                                <label for="first-name" class="control-label"><?php echo $this->lang->line('first_name'); ?> *</label>
                                <input type="text" id="first-name" class="required form-control" maxlength="100" />
                            </div>
                            <div class="form-group">
                                <label for="last-name" class="control-label"><?php echo $this->lang->line('last_name'); ?> *</label>
                                <input type="text" id="last-name" class="required form-control" maxlength="250" />
                            </div>
                            <div class="form-group">
                                <label for="email" class="control-label"><?php echo $this->lang->line('email'); ?> *</label>
                                <input type="text" id="email" class="required form-control" maxlength="250" />
                            </div>
                            <div class="form-group">
                                <label for="phone-number" class="control-label"><?php echo $this->lang->line('phone_number'); ?> *</label>
                                <input type="text" id="phone-number" class="required form-control" maxlength="60" />
                            </div>
                        </div>

                        <div class="col-xs-12 col-sm-6">
                            <div class="form-group">
                                <label for="address" class="control-label"><?php echo $this->lang->line('address'); ?></label>
                                <input type="text" id="address" class="form-control" maxlength="250" />
                            </div>
                            <div class="form-group">
                                <label for="city" class="control-label"><?php echo $this->lang->line('city'); ?></label>
                                <input type="text" id="city" class="form-control" maxlength="120" />
                            </div>
                            <div class="form-group">
                                <label for="zip-code" class="control-label"><?php echo $this->lang->line('zip_code'); ?></label>
                                <input type="text" id="zip-code" class="form-control" maxlength="120" />
                            </div>
                            <div class="form-group">
                                <label for="notes" class="control-label"><?php echo $this->lang->line('notes'); ?></label>
                                <textarea id="notes" maxlength="500" class="form-control" rows="3"></textarea>
                            </div>
                        </div>

                        <em id="form-message" class="text-danger"><?php echo $this->lang->line('fields_are_required'); ?></em>
                    </div>
                </div>

                <div class="command-buttons">
                    <button type="button" id="button-back-3" class="btn button-back btn-default"
                            data-step_index="3"><span class="glyphicon glyphicon-backward"></span>
                        <?php echo $this->lang->line('back'); ?>
                    </button>
                    <button type="button" id="button-next-3" class="btn button-next btn-primary"
                            data-step_index="3">
                        <?php echo $this->lang->line('next'); ?>
                        <span class="glyphicon glyphicon-forward"></span>
                    </button>
                </div>

            </div>

            <?php
                // ------------------------------------------------------
                // APPOINTMENT DATA CONFIRMATION
                // ------------------------------------------------------ ?>

            <div id="wizard-frame-4" class="wizard-frame" style="display:none;">
                <div class="frame-container">
                    <h3 class="frame-title"><?php echo $this->lang->line('step_four_title'); ?></h3>
                    <div class="frame-content row">
                        <div id="appointment-details" class="col-xs-12 col-sm-6"></div>
                        <div id="customer-details" class="col-xs-12 col-sm-6"></div>
                    </div>
                    <?php if ($this->settings_model->get_setting('require_captcha') === '1'): ?>
                    <div class="frame-content row">
                        <div class="col-sm-12 col-md-6">
                            <h4 class="captcha-title">
                                CAPTCHA
                                <small class="glyphicon glyphicon-refresh"></small>
                            </h4>
                            <img class="captcha-image" src="<?php echo site_url('captcha'); ?>">
                            <input class="captcha-text" type="text" value="" />
                            <span id="captcha-hint" class="help-block" style="opacity:0">&nbsp;</span>
                        </div>
                    </div>
                    <?php endif; ?>
                </div>

                <div class="command-buttons">
                    <button type="button" id="button-back-4" class="btn button-back btn-default"
                            data-step_index="4">
                        <span class="glyphicon glyphicon-backward"></span>
                        <?php echo $this->lang->line('back'); ?>
                    </button>
                    <form id="book-appointment-form" style="display:inline-block" method="post">
                        <button id="book-appointment-submit" type="button" class="btn btn-success">
                            <span class="glyphicon glyphicon-ok"></span>
                            <?php
                                echo (!$manage_mode) ? $this->lang->line('confirm')
                                        : $this->lang->line('update');
                            ?>
                        </button>
                        <input type="hidden" name="csrfToken" />
                        <input type="hidden" name="post_data" />
                    </form>


                </div>

            </div>

Email sending file

<title>Appointment Details</title>



    <div id="content" style="padding: 10px 15px;">
        <h2>$email_title</h2>
        <p>$email_message</p>

        <h2>Appointment Details</h2>
        <table id="appointment-details">
            <tr>
                <td class="label" style="padding: 3px;font-weight: bold;">Service</td>
                <td style="padding: 3px;">$appointment_service</td>
            </tr>
            <tr>
                <td class="label" style="padding: 3px;font-weight: bold;">Provider</td>
                <td style="padding: 3px;">$appointment_provider</td>
            </tr>
            <tr>
                <td class="label" style="padding: 3px;font-weight: bold;">Start</td>
                <td style="padding: 3px;">$appointment_start_date</td>
            </tr>
            <tr>
                <td class="label" style="padding: 3px;font-weight: bold;">End</td>
                <td style="padding: 3px;">$appointment_end_date</td>
            </tr>
        </table>

        <h2>Customer Details</h2>
        <table id="customer-details">
            <tr>
                <td class="label" style="padding: 3px;font-weight: bold;">Name</td>
                <td style="padding: 3px;">$customer_name</td>
            </tr>
            <tr>
                <td class="label" style="padding: 3px;font-weight: bold;">Email</td>
                <td style="padding: 3px;">$customer_email</td>
            </tr>
            <tr>
                <td class="label" style="padding: 3px;font-weight: bold;">Phone</td>
                <td style="padding: 3px;">$customer_phone</td>
            </tr>
            <tr>
                <td class="label" style="padding: 3px;font-weight: bold;">Address</td>
                <td style="padding: 3px;">$customer_address</td>
            </tr>
        </table>

        <h2>Appointment Link</h2>
        <a href="$appointment_link" style="width: 600px;">$appointment_link</a>
    </div>


</div>

    
asked by anonymous 22.12.2017 / 12:06

1 answer

0

I have adapted a code that I have here, to try to help you ##

You have informed that your form and sending email is already working. so I will not mind this:

//SEU CODIGO DE AGENDAMENTO.
//supondo que vc envia o sms depois da resposta do e-mail
$email = "[email protected]";
$assunto = "Assunto do e-mail";
$corpo = "Aqui escreve o teu contéudo.";
$cabecalho = "From: [email protected]" . "\r\n" .
        "Reply-To:" . $email . "\r\n" .
        "X-mailer: PHP/" . phpversion();

$assunto = '=?UTF-8?B?' . base64_encode($assunto) . '?=';

if (mail($email, $assunto, $corpo, $cabecalho)) { //se o email for enviado da TRUE e passa pelo if
 $msg = trim($corpo);// supondo ser a msm mensagem
    $url = "http://sitedeenvio.com.br/api/v1/send?cpf=XXXXXXXXXXX&password=XXXXXXXXXX&type=short&numbers=55DDDCELULAR&messages=$msg";
    $link = curl_init();
    curl_setopt($link, CURLOPT_HEADER, 0);
    curl_setopt($link, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($link, CURLOPT_URL, $url);
    $resposta = curl_exec($link); // resposta da sua plataforma de envio de sms
    var_dump($resposta); //resposta do envio do sms.
} else {
    echo 'não enviado!';
}

PHP reference mail

    
22.12.2017 / 12:42