Recherche des tweets de réponse avec l'API Tweeter

This commit is contained in:
hugol
2024-11-17 13:55:25 +01:00
parent 3d386178bf
commit 8dc18553ec
1751 changed files with 379552 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Account;
use Illuminate\Support\Facades\Hash;
class ImportUsersCommand extends Command
{
protected $signature = 'import:users {file}';
protected $description = 'Import users from a text file';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$filePath = $this->argument('file');
if (!file_exists($filePath)) {
$this->error("Le fichier spécifié n'existe pas.");
return 1;
}
$file = fopen($filePath, 'r');
while (($line = fgets($file)) !== false) {
$data = explode(':', trim($line));
if (count($data) < 5) {
$this->error("Format incorrect dans le fichier.");
continue;
}
[$username, $password, $email, $emailPassword, $token] = $data;
Account::create([
'name' => $username,
'password' => $password,
'rambler_email' => $email,
'rambler_password' => $emailPassword,
'auth_token' => $token,
]);
$this->info("Utilisateur {$username} importé avec succès.");
}
fclose($file);
$this->info("Importation terminée.");
return 0;
}
}