Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @package Mautic_Returns
- * @version 1.0
- */
- /*
- Plugin Name: Mautic Returns
- Plugin URI:
- Description: Envia para o Mautic o email do cidadão para ser criado um lead no seguimento de cadastro de eventos
- Author: Grexos
- Version: 1.0
- Author URI: http://grexos.com.br/
- */
- add_action( 'em_booking_add', 'send_mautic', 10, 4 );
- function send_mautic( $a, $b, $c, $d ) {
- if( $c ){
- function mautic_api_post($url, $data){
- $ch = curl_init();
- $username = "fabio.paradela@grexos.com";
- $password = "Grepro123!";
- curl_setopt($ch,CURLOPT_USERPWD, $username . ":" . $password);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_POST, 1);
- if($data != ""){
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
- }
- $output=curl_exec($ch);
- curl_close($ch);
- return $output;
- }
- $array = array(
- 'user_name' => $d['user_name'],
- 'dbem_phone' => $d['dbem_phone'],
- 'user_email' => $d['user_email']
- );
- $url = "https://visie.mautic.visie.com.br/api/contacts/new";
- $contact = array(
- 'firstname' => $array['user_name'],
- 'email' => $array['user_email']
- );
- $x = mautic_api_post($url, $contact);
- $x = json_decode($x);
- // adicionando ao seguimento
- $segment_id = "18";
- $contact_id = $x->contact->id;
- $url_segment = "https://visie.mautic.visie.com.br/api/segments/".$segment_id."/contact/add/".$contact_id;
- $y = mautic_api_post($url_segment,"");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement