Beispiel #1
0
 /** ajax module for validation (Home - welcome) */
 public function ajax_validation_process()
 {
     $access_key = trim($_POST['access_key']);
     $secret_key = trim($_POST['secret_key']);
     $mailin = new Mailin('https://api.sendinblue.com/v1.0', $access_key, $secret_key);
     $response = $mailin->get_attribute('normal');
     if (is_array($response)) {
         if ($response['code'] == 'success') {
             // store api info
             $settings = array('access_key' => $access_key, 'secret_key' => $secret_key);
             update_option(SIB_Manager::main_option_name, $settings);
             // store attribute list
             $attribute_list = $response['data'];
             update_option(SIB_Manager::attribute_list_option_name, $attribute_list);
             // get access_token
             $access_response = $mailin->get_access_tokens();
             $access_token = $access_response['data']['access_token'];
             $token_settings = array('access_token' => $access_token);
             update_option(SIB_Manager::access_token_option_name, $token_settings);
             echo 'success';
         } else {
             echo 'fail';
         }
     } else {
         echo 'fail';
     }
     die;
 }