Spaces:
No application file
No application file
File size: 1,548 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
<?php
namespace MauticPlugin\MauticSocialBundle\Command;
use MauticPlugin\MauticSocialBundle\Entity\Monitoring;
class MonitorTwitterMentionsCommand extends MonitorTwitterBaseCommand
{
/**
* Configure the command, set name and options.
*/
protected function configure()
{
$this->setName('social:monitor:twitter:mentions');
parent::configure();
}
/**
* Search for tweets by mention.
*
* @param Monitoring $monitor
*
* @return bool|array False if missing the twitter handle, otherwise the array response from Twitter
*/
protected function getTweets($monitor)
{
$params = $monitor->getProperties();
$stats = $monitor->getStats();
if (!array_key_exists('handle', $params)) {
$this->output->writeln('No twitter handle was found!');
return false;
}
$mentionsUrl = $this->twitter->getApiUrl('search/tweets');
$requestQuery = [
'q' => '@'.$params['handle'],
'count' => $this->queryCount,
];
// if we have a max id string use it here
if (is_array($stats) && array_key_exists('max_id_str', $stats) && $stats['max_id_str']) {
$requestQuery['since_id'] = $stats['max_id_str'];
}
return $this->twitter->makeRequest($mentionsUrl, $requestQuery);
}
public function getNetworkName(): string
{
return 'twitter';
}
protected static $defaultDescription = 'Searches for mentioned tweets';
}
|