Mautic Community Forums

Twitter Plugin & Cron

hello,



I have not been able to get the twitter plugin to actually do anything, i am able to get it authroized in mautic after that it doesn’t work within mautic when you create a segment and than create a social monitoring with twitter choosing either one the hashtag or mentions neither one will do anything or work. I have received this error from the cron job that is shown. mautic:social:monitoring If someone could take a look at this and see what i can manually do to change things in the code that be great.



Exexuting Monitor Item 11


this shows up in a red box
[SymfonyComponentDebugExceptionFatalThrowableError]
Type error: Argument 2 passed to MauticPluginBundleHelperoAuthHelper::__construct() must be
an instance of SymfonyComponentHttpFoundationRequest, null given, called in /home/www/cms.i4
campaigns.com/app/bundles/PluginBundle/Integration/AbstractIntegration.php on line 967

I have no issues of any kind with any other cron jobs only this one seems to give me serious problems.
i use SSH to do everything as it is. I went to look at teh line 967 that it lists and this is what i found.

lines 960 to 1003 i have copied and pasted.

line 960: switch ($authType) {
case 'basic':
$headers = [
'Authorization' => 'Basic '.base64_encode($this->keys.':'.$this->keys),
];
break;
case 'oauth1a':
$oauthHelper = new oAuthHelper($this, $this->request, $settings);
$headers = $oauthHelper->getAuthorizationHeader($url, $parameters, $method);
break;
case 'oauth2':
if ($bearerToken = $this->getBearerToken()) {
$headers = [
"Authorization: Bearer {$bearerToken}",
//"Content-Type: application/x-www-form-urlencoded;charset=UTF-8"
];
} else {
if (!empty($settings)) {
// Workaround because $settings cannot be manipulated here
$parameters = [
$authTokenKey => $authToken,
];
} else {
$parameters[$authTokenKey] = $authToken;
}

$headers = [
"oauth-token: $authTokenKey",
"Authorization: OAuth {$authToken}",
];
}
break;
case 'key':
$parameters[$authTokenKey] = $authToken;
break;
}
}

return [$parameters, $headers];
}

/**
* Generate the auth login URL. Note that if oauth2, response_type=code is assumed. If this is not the case,
line 1003 * override this function.

this is what is listed in the mautic log file. this is the onlything that is in the log file. this has more info than the cron report shows it has also another file on like 38 that i have also copied down as well.

mautic.NOTICE: SymfonyComponentDebugExceptionFatalThrowableError: Type error: Argument 2 passed to MauticPluginBundleHelperoAuthHelper::__construct() must be an instance of SymfonyComponentHttpFoundationRequest, null given, called in /home/www/cms.i4campaigns.com/app/bundles/PluginBundle/Integration/AbstractIntegration.php on line 967 (uncaught exception) at /home/www/cms.i4campaigns.com/app/bundles/PluginBundle/Helper/oAuthHelper.php line 38 while running console command `mautic:social:monitoring` [] []

oAuthHelper.php file


line: 18

* Class oAuthHelper.
*
* Portions modified from https://code.google.com/p/simple-php-oauth/
*/
class oAuthHelper
{
private $clientId;

private $clientSecret;

private $accessToken;

private $accessTokenSecret;

private $callback;

private $settings;

private $request;

line 38: public function __construct(AbstractIntegration $integration, Request $request, $settings = [])
{
$clientId = $integration->getClientIdKey();
$clientSecret = $integration->getClientSecretKey();
$keys = $integration->getDecryptedApiKeys();
$this->clientId = isset($keys[$clientId]) ? $keys[$clientId] : null;
$this->clientSecret = isset($keys[$clientSecret]) ? $keys[$clientSecret] : null;
$authToken = $integration->getAuthTokenKey();
$this->accessToken = (isset($keys[$authToken])) ? $keys[$authToken] : '';
$this->accessTokenSecret = (isset($settings)) ? $settings : '';
$this->callback = $integration->getAuthCallbackUrl();
$this->settings = $settings;
$this->request = $request;
}
line 51

Thanks

hello,

I have not been able to get the twitter plugin to actually do anything, i am able to get it authroized in mautic after that it doesn’t work within mautic when you create a segment and than create a social monitoring with twitter choosing either one the hashtag or mentions neither one will do anything or work. I have received this error from the cron job that is shown. mautic:social:monitoring If someone could take a look at this and see what i can manually do to change things in the code that be great.

Exexuting Monitor Item 11
-------------this shows up in a red box ------------------------
[SymfonyComponentDebugExceptionFatalThrowableError]
Type error: Argument 2 passed to MauticPluginBundleHelperoAuthHelper::__construct() must be
an instance of SymfonyComponentHttpFoundationRequest, null given, called in /home/www/cms.i4
campaigns.com/app/bundles/PluginBundle/Integration/AbstractIntegration.php on line 967

I have no issues of any kind with any other cron jobs only this one seems to give me serious problems.
i use SSH to do everything as it is. I went to look at teh line 967 that it lists and this is what i found.

lines 960 to 1003 i have copied and pasted.

line 960: switch ($authType) {
case ‘basic’:
$headers = [
‘Authorization’ => ‘Basic ‘.base64_encode($this->keys[‘username’].’:’.$this->keys[‘password’]),
];
break;
case ‘oauth1a’:
$oauthHelper = new oAuthHelper($this, $this->request, $settings);
$headers = $oauthHelper->getAuthorizationHeader($url, $parameters, $method);
break;
case ‘oauth2’:
if ($bearerToken = $this->getBearerToken()) {
$headers = [
“Authorization: Bearer {$bearerToken}”,
//“Content-Type: application/x-www-form-urlencoded;charset=UTF-8”
];
} else {
if (!empty($settings[‘append_auth_token’])) {
// Workaround because $settings cannot be manipulated here
$parameters[‘append_to_query’] = [
$authTokenKey => $authToken,
];
} else {
$parameters[$authTokenKey] = $authToken;
}

                    $headers = [
                        "oauth-token: $authTokenKey",
                        "Authorization: OAuth {$authToken}",
                    ];
                }
                break;
            case 'key':
                $parameters[$authTokenKey] = $authToken;
                break;
        }
    }

    return [$parameters, $headers];
}

/**
 * Generate the auth login URL.  Note that if oauth2, response_type=code is assumed.  If this is not the case,

line 1003 * override this function.

this is what is listed in the mautic log file. this is the onlything that is in the log file. this has more info than the cron report shows it has also another file on like 38 that i have also copied down as well.

mautic.NOTICE: SymfonyComponentDebugExceptionFatalThrowableError: Type error: Argument 2 passed to MauticPluginBundleHelperoAuthHelper::__construct() must be an instance of SymfonyComponentHttpFoundationRequest, null given, called in /home/www/cms.i4campaigns.com/app/bundles/PluginBundle/Integration/AbstractIntegration.php on line 967 (uncaught exception) at /home/www/cms.i4campaigns.com/app/bundles/PluginBundle/Helper/oAuthHelper.php line 38 while running console command mautic:social:monitoring [] []

oAuthHelper.php file

line: 18

  • Class oAuthHelper.

  • Portions modified from https://code.google.com/p/simple-php-oauth/
    */
    class oAuthHelper
    {
    private $clientId;

    private $clientSecret;

    private $accessToken;

    private $accessTokenSecret;

    private $callback;

    private $settings;

    private $request;

line 38: public function __construct(AbstractIntegration $integration, Request $request, $settings = [])
{
$clientId = $integration->getClientIdKey();
$clientSecret = $integration->getClientSecretKey();
$keys = $integration->getDecryptedApiKeys();
$this->clientId = isset($keys[$clientId]) ? $keys[$clientId] : null;
$this->clientSecret = isset($keys[$clientSecret]) ? $keys[$clientSecret] : null;
$authToken = $integration->getAuthTokenKey();
$this->accessToken = (isset($keys[$authToken])) ? $keys[$authToken] : ‘’;
$this->accessTokenSecret = (isset($settings[‘token_secret’])) ? $settings[‘token_secret’] : ‘’;
$this->callback = $integration->getAuthCallbackUrl();
$this->settings = $settings;
$this->request = $request;
}
line 51

Thanks

I managed to fix the issue I done it with 2.8.2

Here is the link http://www.sagarnangare.net/mautic-cron-issue-fix-social-monitoring-command-twitter/

@sagarnangare Thanks for sharing

this problem is old, i haven’t had a problem with this for some time now

@vcdesigns but it helps to others Thanks

Hi,

I just setup the social monitoring. And although I don’t get any error and the user is created in the segment that I have configured I can’t see his tweets. Is this normal ?