douci6541 2016-02-12 08:43
浏览 55

将网站数据库连接到mailchimp列表

I've got a website with a simple form where users can signup, in this form users have to specify a certain group that they want to be a part of.

What i want to do is to connect a group to a mailchimp list so that whenever someone signs up for this particular group they automatically get added to the mailchimp list. They also need to receive the very first campaign.

Thank you!

  • 写回答

2条回答 默认 最新

  • douna3367 2016-02-12 11:27
    关注

    You may want to try a skovmand/mailchimp-laravel package for it:

    Step 1: Adding the dependency to composer.json

    Add this to your composer.json in your Laravel folder. Note: Adding this dependency will automatically setup "mailchimp/mailchimp": "~2.0" too.

    "require": {
        ...
        "skovmand/mailchimp-laravel": "1.*",
        ...
    }
    

    Step 2: Register the service provider

    Register the service provider in config/app.php by inserting into the providers array

    'providers' => [
        ...
        Skovmand\Mailchimp\MailchimpServiceProvider::class,
        ...
    ]
    

    Step 3: From the command-line run

    php artisan vendor:publish --provider="Skovmand\Mailchimp\MailchimpServiceProvider"

    This will publish config/mailchimp.php to your config folder. In this file, insert your Mailchimp API key:

    'apikey' => 'your-api-key-here',
    

    Usage example

    class NewsletterManager 
    {
        protected $mailchimp;
        protected $listId = '1234567890';        // Id of newsletter list
    
        /**
         * Pull the Mailchimp-instance (including API-key) from the IoC-container.
         */
        public function __construct(Mailchimp $mailchimp) 
        {
            $this->mailchimp = $mailchimp;
        }
    
        /**
         * Access the mailchimp lists API
         */
        public function addEmailToList($email) 
        {
            try {
                $this->mailchimp
                    ->lists
                    ->subscribe(
                        $this->listId, 
                        ['email' => $email]
                    );
            } catch (\Mailchimp_List_AlreadySubscribed $e) {
                // do something
            } catch (\Mailchimp_Error $e) {
                // do something
            }
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥30 求解达问题(有红包)