dsda

Flexbe.ru to SmartResponder connector

Dec 23rd, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. <?php
  2.  
  3.     $smartresponder_delid = '000000'; // ID рассылки
  4.     $smartresponder_api_url = 'http://api.smartresponder.ru/subscribers.html'; // URL API для добавления подписчиков
  5.     $debug = 0; // включить отладку?
  6.     $API_KEY = 'FAFAFAAFAFFA'; // Smartresponder API KEY
  7.  
  8.  
  9.     if ($debug==1) {
  10.         ob_start();
  11.         print_r($_POST);
  12.         $out = ob_get_contents();
  13.         file_put_contents('tmp.txt',$out, FILE_APPEND);
  14.         ob_end_clean();
  15.     }
  16.  
  17.     function goit($url,$post){
  18.         $ch = curl_init();
  19.         curl_setopt($ch, CURLOPT_URL, $url);
  20.         curl_setopt($ch, CURLOPT_HEADER, 0);
  21.         curl_setopt($ch, CURLOPT_POST, 1);
  22.         curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  23.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  24.         $out = curl_exec($ch);
  25.         curl_close($ch);
  26.         return $out;
  27.     }
  28.  
  29.  
  30.  
  31.     if (isset($_POST['data'])) {
  32.         $name = $_POST['data']['client']['name'];
  33.         $email = $_POST['data']['client']['email'];
  34.         $smresp_post_data = array(
  35.             'api_key'=>$API_KEY,
  36.             'format'=>'json',
  37.             'action'=>'create',
  38.             'delivery_id'=>$smartresponder_delid,
  39.             'email'=>$email,
  40.             'first_name'=>$name,
  41.         );
  42.         $res = goit($smartresponder_api_url,$smresp_post_data);
  43.         if ($debug==1) {
  44.             ob_start();
  45.             print_r($res);
  46.             $out = ob_get_contents();
  47.             file_put_contents('tmp.txt',$out, FILE_APPEND);
  48.             ob_end_clean();
  49.         }
  50.  
  51.     } else {
  52.         exit();
  53.     }
  54.    
  55.     exit();
  56.  
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment