Mise en place de la verification des credentials avec reconnexion automatique
This commit is contained in:
@@ -377,7 +377,7 @@ class APIController extends Controller
|
|||||||
$cursor = null;
|
$cursor = null;
|
||||||
|
|
||||||
// Nombre de tours
|
// Nombre de tours
|
||||||
$maxLoops = 10;
|
$maxLoops = 5;
|
||||||
|
|
||||||
// Boucle pour exécuter 5 tours
|
// Boucle pour exécuter 5 tours
|
||||||
for ($loop = 1; $loop <= $maxLoops; $loop++) {
|
for ($loop = 1; $loop <= $maxLoops; $loop++) {
|
||||||
@@ -537,6 +537,70 @@ class APIController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function check($user)
|
||||||
|
{
|
||||||
|
$stack = $this->Oauth1($user);
|
||||||
|
|
||||||
|
// Créer le client Guzzle avec le handler stack
|
||||||
|
$client = new Client([
|
||||||
|
'base_uri' => 'https://api.twitter.com/1.1/',
|
||||||
|
'handler' => $stack,
|
||||||
|
'proxy' => [
|
||||||
|
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
try{
|
||||||
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
||||||
|
$res = $client->get('account/verify_credentials.json', [
|
||||||
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
||||||
|
'auth' => 'oauth' // Assurez-vous que l'authentification OAuth est incluse
|
||||||
|
]);
|
||||||
|
|
||||||
|
$suspended = json_decode($res->getBody()->getContents(), true);
|
||||||
|
|
||||||
|
if($suspended['suspended'] === true){
|
||||||
|
$user->enable = false;
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
$text = "Le compte ".$user->name.' a été suspendu';
|
||||||
|
Http::get('https://api.telegram.org/bot6784810105:AAEq3emnkRwdyvCLC-iqdIjVJ2Ke6HwwGjg/sendMessage', [
|
||||||
|
'chat_id' => '1970698501', // Remplacez par votre chat_id
|
||||||
|
'text' => $text,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}catch (\Exception $e){
|
||||||
|
$connexion = (new AccountController)->login($user->id);
|
||||||
|
|
||||||
|
if($connexion){
|
||||||
|
$text = "Le compte ".$user->name.' a été synchronisé';
|
||||||
|
Http::get('https://api.telegram.org/bot6784810105:AAEq3emnkRwdyvCLC-iqdIjVJ2Ke6HwwGjg/sendMessage', [
|
||||||
|
'chat_id' => '1970698501', // Remplacez par votre chat_id
|
||||||
|
'text' => $text,
|
||||||
|
]);
|
||||||
|
}elseif(!$connexion){
|
||||||
|
$user->enable = false;
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
$text = "Le compte ".$user->name.' n\'a pas pu être synchronisé. Il a été désactivé';
|
||||||
|
Http::get('https://api.telegram.org/bot6784810105:AAEq3emnkRwdyvCLC-iqdIjVJ2Ke6HwwGjg/sendMessage', [
|
||||||
|
'chat_id' => '1970698501', // Remplacez par votre chat_id
|
||||||
|
'text' => $text,
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
$user->enable = false;
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
$text = "Problème sur le compte ".$user->name.'. Il a été désactivé';
|
||||||
|
Http::get('https://api.telegram.org/bot6784810105:AAEq3emnkRwdyvCLC-iqdIjVJ2Ke6HwwGjg/sendMessage', [
|
||||||
|
'chat_id' => '1970698501', // Remplacez par votre chat_id
|
||||||
|
'text' => $text,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function Oauth1($user)
|
private function Oauth1($user)
|
||||||
{
|
{
|
||||||
// Créer le stack pour gérer l'authentification OAuth
|
// Créer le stack pour gérer l'authentification OAuth
|
||||||
|
|||||||
@@ -2,13 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Jobs\ProcessNews;
|
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Queue;
|
|
||||||
use App\Http\Controllers\APIController;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Webklex\PHPIMAP\ClientManager;
|
use Webklex\PHPIMAP\ClientManager;
|
||||||
|
|
||||||
class AccountController extends Controller
|
class AccountController extends Controller
|
||||||
@@ -17,145 +12,181 @@ class AccountController extends Controller
|
|||||||
{
|
{
|
||||||
$user = Account::find($id);
|
$user = Account::find($id);
|
||||||
|
|
||||||
$username = $user->name;
|
try{
|
||||||
$password = $user->password;
|
$username = $user->name;
|
||||||
$email = $user->rambler_email;
|
$password = $user->password;
|
||||||
$rambler_password = $user->rambler_password;
|
$email = $user->rambler_email;
|
||||||
|
$rambler_password = $user->rambler_password;
|
||||||
|
|
||||||
$proxy = 'http://xtjnmwvl-'.$id.':lp7iv1lq9glu@p.webshare.io:80';
|
$proxy = 'http://xtjnmwvl-'.$id.':lp7iv1lq9glu@p.webshare.io:80';
|
||||||
|
|
||||||
// Clés et jetons de Twitter
|
// Clés et jetons de Twitter
|
||||||
$TW_CONSUMER_KEY = '3nVuSoBZnx6U4vzUxf5w';
|
$TW_CONSUMER_KEY = '3nVuSoBZnx6U4vzUxf5w';
|
||||||
$TW_CONSUMER_SECRET = 'Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys';
|
$TW_CONSUMER_SECRET = 'Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys';
|
||||||
$TW_ANDROID_BASIC_TOKEN = 'Basic ' . base64_encode("$TW_CONSUMER_KEY:$TW_CONSUMER_SECRET");
|
$TW_ANDROID_BASIC_TOKEN = 'Basic ' . base64_encode("$TW_CONSUMER_KEY:$TW_CONSUMER_SECRET");
|
||||||
|
|
||||||
// Requête pour obtenir le bearer token
|
// Requête pour obtenir le bearer token
|
||||||
$response = Http::withHeaders([
|
$response = Http::withHeaders([
|
||||||
'Authorization' => $TW_ANDROID_BASIC_TOKEN,
|
'Authorization' => $TW_ANDROID_BASIC_TOKEN,
|
||||||
'Content-Type' => 'application/x-www-form-urlencoded',
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||||
])->asForm()->post('https://api.twitter.com/oauth2/token', [
|
])->asForm()->post('https://api.twitter.com/oauth2/token', [
|
||||||
'grant_type' => 'client_credentials',
|
'grant_type' => 'client_credentials',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$bearerToken = collect($response->json())->implode(' ');
|
$bearerToken = collect($response->json())->implode(' ');
|
||||||
|
|
||||||
// Requête pour obtenir le guest token
|
// Requête pour obtenir le guest token
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
|
||||||
curl_setopt_array($curl, array(
|
curl_setopt_array($curl, array(
|
||||||
CURLOPT_URL => 'https://api.twitter.com/1.1/guest/activate.json',
|
CURLOPT_URL => 'https://api.twitter.com/1.1/guest/activate.json',
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_ENCODING => '',
|
CURLOPT_ENCODING => '',
|
||||||
CURLOPT_MAXREDIRS => 10,
|
CURLOPT_MAXREDIRS => 10,
|
||||||
CURLOPT_TIMEOUT => 0,
|
CURLOPT_TIMEOUT => 0,
|
||||||
CURLOPT_FOLLOWLOCATION => true,
|
CURLOPT_FOLLOWLOCATION => true,
|
||||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||||
CURLOPT_HTTPHEADER => array(
|
CURLOPT_HTTPHEADER => array(
|
||||||
'Authorization: ' . $bearerToken
|
'Authorization: ' . $bearerToken
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = curl_exec($curl);
|
$response = curl_exec($curl);
|
||||||
|
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
$reponse = json_decode($response, true);
|
$reponse = json_decode($response, true);
|
||||||
$guestToken = $reponse['guest_token'];
|
$guestToken = $reponse['guest_token'];
|
||||||
|
|
||||||
// Configuration des en-têtes pour les futures requêtes
|
// Configuration des en-têtes pour les futures requêtes
|
||||||
$twitterHeaders = [
|
$twitterHeaders = [
|
||||||
'Authorization' => $bearerToken,
|
'Authorization' => $bearerToken,
|
||||||
'User-Agent' => 'TwitterAndroid/10.46.0-release.0 (310460000-r-0) Android+SDK+built+for+x86/11 (unknown;Android+SDK+built+for+x86;Android;sdk_phone_x86;0;;1;2013)',
|
'User-Agent' => 'TwitterAndroid/10.46.0-release.0 (310460000-r-0) Android+SDK+built+for+x86/11 (unknown;Android+SDK+built+for+x86;Android;sdk_phone_x86;0;;1;2013)',
|
||||||
'x-twitter-api-version' => '5',
|
'x-twitter-api-version' => '5',
|
||||||
'x-twitter-client' => 'TwitterAndroid',
|
'x-twitter-client' => 'TwitterAndroid',
|
||||||
'x-twitter-client-version' => '10.46.0-release.0',
|
'x-twitter-client-version' => '10.46.0-release.0',
|
||||||
'x-twitter-active-user' => 'yes',
|
'x-twitter-active-user' => 'yes',
|
||||||
'os-version' => '30',
|
'os-version' => '30',
|
||||||
'x-twitter-client-language' => 'en-US',
|
'x-twitter-client-language' => 'en-US',
|
||||||
'x-attest-token' => 'no_token',
|
'x-attest-token' => 'no_token',
|
||||||
'X-Guest-Token' => $guestToken,
|
'X-Guest-Token' => $guestToken,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Initialisation de la session avec Laravel HTTP pour le flux de connexion
|
// Initialisation de la session avec Laravel HTTP pour le flux de connexion
|
||||||
// Étape 1 : Commencer le flux de connexion
|
// Étape 1 : Commencer le flux de connexion
|
||||||
$task1 = Http::withOptions([
|
$task1 = Http::withOptions([
|
||||||
'proxy' => $proxy
|
'proxy' => $proxy
|
||||||
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json?flow_name=login&api_version=1&known_device_token=', [
|
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json?flow_name=login&api_version=1&known_device_token=', [
|
||||||
'input_flow_data' => [
|
'input_flow_data' => [
|
||||||
'country_code' => null,
|
'country_code' => null,
|
||||||
'flow_context' => [
|
'flow_context' => [
|
||||||
'start_location' => [
|
'start_location' => [
|
||||||
'location' => 'deeplink',
|
'location' => 'deeplink',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'requested_variant' => null,
|
||||||
|
'target_user_id' => 0,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Stockage de l'en-tête 'att' pour les futures requêtes
|
||||||
|
$twitterHeaders['att'] = $task1->header('att');
|
||||||
|
|
||||||
|
sleep(5);
|
||||||
|
|
||||||
|
// Étape 2 : Saisie du nom d'utilisateur
|
||||||
|
$task2 = Http::withOptions([
|
||||||
|
'proxy' => $proxy
|
||||||
|
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
||||||
|
'flow_token' => $task1->json()['flow_token'],
|
||||||
|
'subtask_inputs' => [
|
||||||
|
[
|
||||||
|
'enter_text' => [
|
||||||
|
'text' => $username,
|
||||||
|
'link' => 'next_link',
|
||||||
|
],
|
||||||
|
'subtask_id' => 'LoginEnterUserIdentifier',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'requested_variant' => null,
|
]);
|
||||||
'target_user_id' => 0,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Stockage de l'en-tête 'att' pour les futures requêtes
|
sleep(5);
|
||||||
$twitterHeaders['att'] = $task1->header('att');
|
|
||||||
|
|
||||||
sleep(5);
|
if ($task2->json()['subtasks'][0]['subtask_id'] === 'LoginEnterAlternateIdentifierSubtask') {
|
||||||
|
$task2bis = Http::withOptions([
|
||||||
// Étape 2 : Saisie du nom d'utilisateur
|
'proxy' => $proxy
|
||||||
$task2 = Http::withOptions([
|
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
||||||
'proxy' => $proxy
|
'flow_token' => $task2->json()['flow_token'],
|
||||||
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
'subtask_inputs' => [
|
||||||
'flow_token' => $task1->json()['flow_token'],
|
[
|
||||||
'subtask_inputs' => [
|
'enter_text' => [
|
||||||
[
|
'text' => $email,
|
||||||
'enter_text' => [
|
'link' => 'next_link',
|
||||||
'text' => $username,
|
],
|
||||||
'link' => 'next_link',
|
'subtask_id' => 'LoginEnterAlternateIdentifierSubtask',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'subtask_id' => 'LoginEnterUserIdentifier',
|
]);
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
sleep(5);
|
$task2 = $task2bis;
|
||||||
|
}
|
||||||
|
|
||||||
if ($task2->json()['subtasks'][0]['subtask_id'] === 'LoginEnterAlternateIdentifierSubtask') {
|
sleep(5);
|
||||||
$task2bis = Http::withOptions([
|
|
||||||
|
// Étape 3 : Saisie du mot de passe
|
||||||
|
$task3 = Http::withOptions([
|
||||||
'proxy' => $proxy
|
'proxy' => $proxy
|
||||||
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
||||||
'flow_token' => $task2->json()['flow_token'],
|
'flow_token' => $task2->json()['flow_token'],
|
||||||
'subtask_inputs' => [
|
'subtask_inputs' => [
|
||||||
[
|
[
|
||||||
'enter_text' => [
|
'enter_password' => [
|
||||||
'text' => $email,
|
'password' => $password,
|
||||||
'link' => 'next_link',
|
'link' => 'next_link',
|
||||||
],
|
],
|
||||||
'subtask_id' => 'LoginEnterAlternateIdentifierSubtask',
|
'subtask_id' => 'LoginEnterPassword',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$task2 = $task2bis;
|
if ($task3->json()['subtasks'][0]['subtask_id'] === 'LoginAcid') {
|
||||||
}
|
sleep(5);
|
||||||
|
if(isset($task3->json()['subtasks'][0]['enter_text']['hint_text'])){
|
||||||
|
$code = $this->getCodeFromLastEmail($email, $rambler_password);
|
||||||
|
$task3bis = Http::withOptions([
|
||||||
|
'proxy' => $proxy
|
||||||
|
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
||||||
|
'flow_token' => $task3->json()['flow_token'],
|
||||||
|
'subtask_inputs' => [
|
||||||
|
[
|
||||||
|
'enter_text' => [
|
||||||
|
'text' => $code,
|
||||||
|
'link' => 'next_link',
|
||||||
|
],
|
||||||
|
'subtask_id' => 'LoginAcid',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}else{
|
||||||
|
$task3bis = Http::withOptions([
|
||||||
|
'proxy' => $proxy
|
||||||
|
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
||||||
|
'flow_token' => $task3->json()['flow_token'],
|
||||||
|
'subtask_inputs' => [
|
||||||
|
[
|
||||||
|
'enter_text' => [
|
||||||
|
'text' => $email,
|
||||||
|
'link' => 'next_link',
|
||||||
|
],
|
||||||
|
'subtask_id' => 'LoginAcid',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$task3 = $task3bis;
|
||||||
|
}
|
||||||
|
|
||||||
sleep(5);
|
if($task3->json()['subtasks'][0]['subtask_id'] === 'LoginEnterOtp'){
|
||||||
|
|
||||||
// Étape 3 : Saisie du mot de passe
|
|
||||||
$task3 = Http::withOptions([
|
|
||||||
'proxy' => $proxy
|
|
||||||
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
|
||||||
'flow_token' => $task2->json()['flow_token'],
|
|
||||||
'subtask_inputs' => [
|
|
||||||
[
|
|
||||||
'enter_password' => [
|
|
||||||
'password' => $password,
|
|
||||||
'link' => 'next_link',
|
|
||||||
],
|
|
||||||
'subtask_id' => 'LoginEnterPassword',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($task3->json()['subtasks'][0]['subtask_id'] === 'LoginAcid') {
|
|
||||||
sleep(5);
|
|
||||||
if(isset($task3->json()['subtasks'][0]['enter_text']['hint_text'])){
|
|
||||||
$code = $this->getCodeFromLastEmail($email, $rambler_password);
|
$code = $this->getCodeFromLastEmail($email, $rambler_password);
|
||||||
$task3bis = Http::withOptions([
|
$task3bis = Http::withOptions([
|
||||||
'proxy' => $proxy
|
'proxy' => $proxy
|
||||||
@@ -167,60 +198,29 @@ class AccountController extends Controller
|
|||||||
'text' => $code,
|
'text' => $code,
|
||||||
'link' => 'next_link',
|
'link' => 'next_link',
|
||||||
],
|
],
|
||||||
'subtask_id' => 'LoginAcid',
|
'subtask_id' => 'LoginEnterOtp',
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}else{
|
|
||||||
$task3bis = Http::withOptions([
|
|
||||||
'proxy' => $proxy
|
|
||||||
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
|
||||||
'flow_token' => $task3->json()['flow_token'],
|
|
||||||
'subtask_inputs' => [
|
|
||||||
[
|
|
||||||
'enter_text' => [
|
|
||||||
'text' => $email,
|
|
||||||
'link' => 'next_link',
|
|
||||||
],
|
|
||||||
'subtask_id' => 'LoginAcid',
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
$task3 = $task3bis;
|
||||||
}
|
}
|
||||||
$task3 = $task3bis;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($task3->json()['subtasks'][0]['subtask_id'] === 'LoginEnterOtp'){
|
if($task3->json()['subtasks']['0']['subtask_id'] == 'LoginSuccessSubtask' ){
|
||||||
$code = $this->getCodeFromLastEmail($email, $rambler_password);
|
$user->update([
|
||||||
$task3bis = Http::withOptions([
|
'oauth_token' => $task3->json()['subtasks']['0']['open_account']['oauth_token'],
|
||||||
'proxy' => $proxy
|
'oauth_token_secret' => $task3->json()['subtasks']['0']['open_account']['oauth_token_secret'],
|
||||||
])->withHeaders($twitterHeaders)->post('https://api.twitter.com/1.1/onboarding/task.json', [
|
'known_device_token' => $task3->json()['subtasks']['0']['open_account']['known_device_token'],
|
||||||
'flow_token' => $task3->json()['flow_token'],
|
'enable' => true,
|
||||||
'subtask_inputs' => [
|
]);
|
||||||
[
|
|
||||||
'enter_text' => [
|
|
||||||
'text' => $code,
|
|
||||||
'link' => 'next_link',
|
|
||||||
],
|
|
||||||
'subtask_id' => 'LoginEnterOtp',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
$task3 = $task3bis;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($task3->json()['subtasks']['0']['subtask_id'] == 'LoginSuccessSubtask' ){
|
return true;
|
||||||
$user->update([
|
}else{
|
||||||
'oauth_token' => $task3->json()['subtasks']['0']['open_account']['oauth_token'],
|
return false;
|
||||||
'oauth_token_secret' => $task3->json()['subtasks']['0']['open_account']['oauth_token_secret'],
|
}
|
||||||
'known_device_token' => $task3->json()['subtasks']['0']['open_account']['known_device_token'],
|
}catch (\Exception $e){
|
||||||
'enable' => true,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private function getCodeFromLastEmail($email, $password)
|
private function getCodeFromLastEmail($email, $password)
|
||||||
{
|
{
|
||||||
@@ -269,73 +269,4 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tweetnews()
|
|
||||||
{
|
|
||||||
// Vérifier si la queue est vide (en fonction de votre driver)
|
|
||||||
$queue = Queue::getDefaultDriver(); // Par défaut, c'est 'default'
|
|
||||||
|
|
||||||
$jobsCount = Queue::size($queue);
|
|
||||||
|
|
||||||
if ($jobsCount === 0) {
|
|
||||||
|
|
||||||
$accounts = Account::where('enable', true)->get();
|
|
||||||
|
|
||||||
foreach($accounts as $user){
|
|
||||||
|
|
||||||
$API = new APIController();
|
|
||||||
|
|
||||||
//On check les notifs
|
|
||||||
$API->unread($user);
|
|
||||||
|
|
||||||
if (Cache::has('news')) {
|
|
||||||
$news = Cache::get('news');
|
|
||||||
}else{
|
|
||||||
$news = $API->newstweet($user);
|
|
||||||
}
|
|
||||||
|
|
||||||
shuffle($news);
|
|
||||||
|
|
||||||
$nb = rand(1,3);
|
|
||||||
|
|
||||||
if (count($news) >= $nb) {
|
|
||||||
$selectedArticles = array_slice($news, 0, $nb);
|
|
||||||
|
|
||||||
foreach ($selectedArticles as $article) {
|
|
||||||
|
|
||||||
$tweetid = $article['conversation_id_str'];
|
|
||||||
$API->retweet($user, $tweetid);
|
|
||||||
sleep(15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public
|
|
||||||
function auto($contestId)
|
|
||||||
{
|
|
||||||
$contest = Contest::find($contestId);
|
|
||||||
|
|
||||||
if (!$contest) {
|
|
||||||
session()->flash('error', 'Concours introuvable.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
flash()->success('Concours ' . $contest->name . ' en cours de participation');
|
|
||||||
|
|
||||||
// Récupération des comptes activés
|
|
||||||
$accounts = Account::where('enable', true)->get();
|
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
ProcessTweet::dispatch($contest->id, $account->id); // Envoi du tweet pour participer
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mise à jour du concours pour indiquer qu'il a été participé
|
|
||||||
$contest->participated = true;
|
|
||||||
$contest->save();
|
|
||||||
|
|
||||||
// Recharger les concours
|
|
||||||
$this->resetPage(); // Reset pagination to the first page
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,4 @@ Route::view('profile', 'profile.edit')
|
|||||||
Route::get('/aplifier/list', [ContestController::class, 'twitterlist']);
|
Route::get('/aplifier/list', [ContestController::class, 'twitterlist']);
|
||||||
Route::get('/aplifier/search', [ContestController::class, 'searchcontest']);
|
Route::get('/aplifier/search', [ContestController::class, 'searchcontest']);
|
||||||
|
|
||||||
Route::get('/unread/{user}', [\App\Http\Controllers\APIController::class, 'unread']);
|
|
||||||
|
|
||||||
Route::get('/api/news', [\App\Http\Controllers\AccountController::class, 'tweetnews']);
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user