%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/saggita.com.mx/wp-content/plugins/Conexion CF7/
Upload File :
Create Path :
Current File : /var/www/saggita.com.mx/wp-content/plugins/Conexion CF7/cf7-api-sender.php

<?php
/**
 * Plugin Name: Conexion CF7.
 * Plugin URI: http://dsr.mx
 * Author: Bsystems
 * Author URI: http://dsr.mx
 * Description: El plugin realiza conexión al webservice de Bsystems del formulario de CF7, esto para la adaptación de Wordpress a PHP
 * Version: 1.0.0
 * License: 1.0.9
 * License URL: http://dsr.mx/licenses/gpl-2.2.txt
 * text-domain: prefix-plugin-name
 */

add_action( 'wpcf7_mail_sent', 'bsys_cf7_api_sender' );

function bsys_cf7_api_sender( $contact_form ) {
    $title = $contact_form->title;

    if ( $title === 'Lead' ) {
        $submission = WPCF7_Submission::get_instance();

        if ( $submission ) {
            $posted_data = $submission->get_posted_data();
            $nombres = $posted_data['your-name'];
            $telefono = $posted_data['tel-671'];
            $email = $posted_data['your-email'];
			$comentario = $posted_data['your-message'];
            $medio = isset( $posted_data['medio'] ) ? implode( ', ', $posted_data['medio'] ) : '';
			//$medio = $posted_data['medio'];
            $agenda = isset( $posted_data['text-157'] ) ? $posted_data['text-157'] : '';
            //$empresatama = isset( $posted_data['empresatam'] ) ? implode( ', ', $posted_data['empresatam'] ) : '';
            //$medios = isset( $posted_data['medio'] ) ? implode( ', ', $posted_data['medio'] ) : '';
            // Cadena Medios
            $comment = 'Comentario: ' . $comentario . ' | Medio que quiere ser contactado: ' . $medio . ' | Cita agendada de la visita: ' . $agenda;


            
            $req_array = array(
                'method' => 'POST',
                'type'   => 'fnLeadWP',
                'access' => 10,
    			'project' => 10,
    			'company' =>2,
                'name'    => $nombres,
                'celular'   => $telefono,
                'email'   => $email,
                'comment' => $comment

            );

            $url = 'https://bsys.mx/siga_ventas/ws_leads_ventas/';

            // Codificar el arreglo como JSON
            $req_json = json_encode( $req_array );

            // Hacer la solicitud
            $response = wp_remote_post( $url, array(
                'body' => $req_json,
                'headers' => array(
                    'Content-Type' => 'application/json'
                )
            ));

            if ( is_wp_error( $response ) ) {
                error_log( 'Error sending data to webservice: ' . $response->get_error_message() );
            }

            error_log( 'Webservice  ' . print_r( $response, true ) );

            return;
        }
    }
}



Zerion Mini Shell 1.0