Advertisement
Guest User

Untitled

a guest
Sep 4th, 2017
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2. /**
  3. * @package Mautic_Returns
  4. * @version 1.0
  5. */
  6. /*
  7. Plugin Name: Mautic Returns
  8. Plugin URI:
  9. Description: Envia para o Mautic o email do cidadão para ser criado um lead no seguimento de cadastro de eventos
  10. Author: Grexos
  11. Version: 1.0
  12. Author URI: http://grexos.com.br/
  13. */
  14.  
  15.  
  16. add_action( 'em_booking_add', 'send_mautic', 10, 4 );
  17.  
  18.  
  19. function send_mautic( $a, $b, $c, $d ) {
  20.  
  21. if( $c ){
  22.  
  23. function mautic_api_post($url, $data){
  24.  
  25. $ch = curl_init();
  26.  
  27. $username = "fabio.paradela@grexos.com";
  28. $password = "Grepro123!";
  29.  
  30. curl_setopt($ch,CURLOPT_USERPWD, $username . ":" . $password);
  31. curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  32.  
  33. curl_setopt($ch,CURLOPT_URL,$url);
  34. curl_setopt($ch, CURLOPT_POST, 1);
  35. if($data != ""){
  36. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  37. }
  38. $output=curl_exec($ch);
  39. curl_close($ch);
  40. return $output;
  41. }
  42.  
  43. $array = array(
  44. 'user_name' => $d['user_name'],
  45. 'dbem_phone' => $d['dbem_phone'],
  46. 'user_email' => $d['user_email']
  47. );
  48.  
  49.  
  50. $url = "https://visie.mautic.visie.com.br/api/contacts/new";
  51.  
  52. $contact = array(
  53. 'firstname' => $array['user_name'],
  54. 'email' => $array['user_email']
  55. );
  56.  
  57. $x = mautic_api_post($url, $contact);
  58. $x = json_decode($x);
  59. // adicionando ao seguimento
  60. $segment_id = "18";
  61. $contact_id = $x->contact->id;
  62. $url_segment = "https://visie.mautic.visie.com.br/api/segments/".$segment_id."/contact/add/".$contact_id;
  63. $y = mautic_api_post($url_segment,"");
  64.  
  65. }
  66.  
  67. }
  68.  
  69.  
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement