コード例 #1
0
 public static function getDataApi()
 {
     $obj = new Mailjet();
     if (self::$data_api === null) {
         self::$data_api = mailjetdata::getInstance();
         self::$data_api->setKeys($obj->getAccountSettingsKey('API_KEY'), $obj->getAccountSettingsKey('SECRET_KEY'));
     }
     return self::$data_api;
 }
コード例 #2
0
        $mailjet = Tools::jsonDecode(Tools::getValue('mailjet'));
        $data = $mailjet->data;
    } else {
        $data = new stdClass();
    }
}
require_once _PS_MODULE_DIR_ . 'mailjet/mailjet.php';
require_once _PS_MODULE_DIR_ . 'mailjet/classes/MailJetLog.php';
$mj = new Mailjet();
MailJetLog::init();
if (Tools::getIsset('response')) {
    $response = (object) Tools::getValue('response');
}
if ($data->next_step_url) {
    if (!empty($response) && ($response->message == 'last change of campaigns parameters' || $response->message == 'send details saved successfully')) {
        $mj_data = new Mailjet_Api($mj->getAccountSettingsKey('API_KEY'), $mj->getAccountSettingsKey('SECRET_KEY'));
        $campaignId = (int) $data->campaign_id;
        $html = $mj_data->data('newsletter', $campaignId, 'HTML', 'text/html', null, 'GET', 'LAST')->getResponse();
        /* On enregistre la campagne en BDD et on génère un token */
        $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'mj_campaign WHERE campaign_id = ' . $campaignId;
        $res_campaign = Db::getInstance()->GetRow($sql);
        if (empty($res_campaign)) {
            $token_presta = md5(uniqid('mj', true));
            $sql = 'INSERT INTO ' . _DB_PREFIX_ . 'mj_campaign (campaign_id, token_presta, date_add)
			VALUES (' . $campaignId . ', \'' . $token_presta . '\', NOW())';
            Db::getInstance()->Execute($sql);
            $sql = 'SELECT * FROM ' . _DB_PREFIX_ . 'mj_campaign WHERE campaign_id = ' . $campaignId;
            $res_campaign = Db::getInstance()->GetRow($sql);
        }
        $regexp = '<a\\s[^>]*href=(\\"??)([^\\" >]*?)\\1[^>]*>(.*)<\\/a>';
        preg_match_all("/{$regexp}/siU", $html, $liens);