Mautic Cron Issue: Fix for Social Monitoring Command for Twitter

Social monitoring is an extremely useful feature in Mautic. With this, one can easily monitor and record mentions and hashtags tweets. A very useful data is captured using this Mautic plugin.

When I attempted to configure my Mautic installation using steps here, I thought it would be an easy things to capture data. but later I realized to set up a cron to timely fetch data from twitter to Mautic. I then setup a cron job as given in this link. But I was constantly getting below error from cron.

  Catchable Fatal Error: Argument 2 passed to Mautic\PluginBundle\Helper\oAuthHelper::__construct() must be an instance of Symfony\Component\HttpFoundation\Request, null given, called in /home/sagnan3/ on line 1122 and defined

mautic:social:monitoring [--mid [MID]] [--batch-size BATCH-SIZE] [--query-count [QUERY-COUNT]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-s|--shell] [--process-isolation] [-e|--env ENV] [--no-debug] [--] <command>

After few searches, I found a solution on githup discussion for Mautic.

Please note that I did this fix on Mautic version of 2.8.2. I think this issue mainly raised after release of 2.8.1. I found several discussions and solutions around those versions.

Below are the code and steps I followed to fix social media monitoring cron issue. I needed to edit 2 files basically.

  1. app/bundles/PluginBundle/Helper/oAuthHelper.php
  2. plugins/MauticSocialBundle/Integration/SocialIntegration.php

Step 1: Search for below line in app/bundles/PluginBundle/Helper/oAuthHelper.php file Line no 38.

public function __construct(AbstractIntegration $integration, Request $request, $settings = [])

and replace with below

public function __construct(AbstractIntegration $integration, Request $request = null, $settings = [])

Step 2: Add below instruction

if (!$this->session) {
            return null;

right after opening Line no 227.

protected function getContactAccessToken(&$socialCache)

Now run your cron job. You will start receiving leads.

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons
%d bloggers like this: