Mise en place des adresses poxy en BDD
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Account;
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\HandlerStack;
|
use GuzzleHttp\HandlerStack;
|
||||||
use GuzzleHttp\Subscriber\Oauth\Oauth1;
|
use GuzzleHttp\Subscriber\Oauth\Oauth1;
|
||||||
@@ -31,7 +30,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/graphql/',
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -82,7 +81,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/graphql/',
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -139,7 +138,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/graphql/',
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -207,7 +206,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/1.1/',
|
'base_uri' => 'https://api.twitter.com/1.1/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -217,7 +216,7 @@ class APIController extends Controller
|
|||||||
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
||||||
'auth' => 'oauth' // Assurez-vous que l'authentification OAuth est incluse
|
'auth' => 'oauth' // Assurez-vous que l'authentification OAuth est incluse
|
||||||
]);
|
]);
|
||||||
sleep(15);
|
sleep(30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +229,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/graphql/',
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -261,7 +260,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/graphql/',
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -314,7 +313,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/2/',
|
'base_uri' => 'https://api.twitter.com/2/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -374,7 +373,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/graphql/',
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -451,7 +450,7 @@ class APIController extends Controller
|
|||||||
// Vérifier si l'entrée contient un tweet
|
// Vérifier si l'entrée contient un tweet
|
||||||
if (isset($entry['content']['items'][0]['item']['content']['tweetResult'])) {
|
if (isset($entry['content']['items'][0]['item']['content']['tweetResult'])) {
|
||||||
// Récupérer le texte complet du tweet
|
// Récupérer le texte complet du tweet
|
||||||
$tweet= $entry['content']['items'][0]['item']['content']['tweetResult']['result']['legacy']['full_text'] ?? '';
|
$tweet = $entry['content']['items'][0]['item']['content']['tweetResult']['result']['legacy']['full_text'] ?? '';
|
||||||
// Supprimer les hashtags
|
// Supprimer les hashtags
|
||||||
$tweet = preg_replace('/#\w+\s?/', '', $tweet);
|
$tweet = preg_replace('/#\w+\s?/', '', $tweet);
|
||||||
|
|
||||||
@@ -478,8 +477,6 @@ class APIController extends Controller
|
|||||||
public function newstweet($user)
|
public function newstweet($user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$user = Account::find($user);
|
|
||||||
|
|
||||||
$stack = $this->Oauth1($user);
|
$stack = $this->Oauth1($user);
|
||||||
|
|
||||||
$newArray = [];
|
$newArray = [];
|
||||||
@@ -504,7 +501,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/graphql/',
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -588,8 +585,6 @@ class APIController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dd($newArray);
|
|
||||||
|
|
||||||
Cache::put('news', $newArray, 1800);
|
Cache::put('news', $newArray, 1800);
|
||||||
|
|
||||||
return $newArray;
|
return $newArray;
|
||||||
@@ -605,7 +600,7 @@ class APIController extends Controller
|
|||||||
'base_uri' => 'https://api.twitter.com/1.1/',
|
'base_uri' => 'https://api.twitter.com/1.1/',
|
||||||
'handler' => $stack,
|
'handler' => $stack,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'http' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
'http' => $user->proxy,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class AccountController extends Controller
|
|||||||
$email = $user->rambler_email;
|
$email = $user->rambler_email;
|
||||||
$rambler_password = $user->rambler_password;
|
$rambler_password = $user->rambler_password;
|
||||||
|
|
||||||
$proxy = 'http://xtjnmwvl-'.$id.':lp7iv1lq9glu@p.webshare.io:80';
|
$proxy = $user->proxy;
|
||||||
|
|
||||||
// Clés et jetons de Twitter
|
// Clés et jetons de Twitter
|
||||||
$TW_CONSUMER_KEY = '3nVuSoBZnx6U4vzUxf5w';
|
$TW_CONSUMER_KEY = '3nVuSoBZnx6U4vzUxf5w';
|
||||||
@@ -225,7 +225,7 @@ class AccountController extends Controller
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}catch (\Exception $e){
|
}catch (\Exception $e){
|
||||||
return false;
|
return $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -241,7 +241,7 @@ class AccountController extends Controller
|
|||||||
'host' => 'imap.rambler.ru',
|
'host' => 'imap.rambler.ru',
|
||||||
'port' => '993',
|
'port' => '993',
|
||||||
'encryption' => 'ssl',
|
'encryption' => 'ssl',
|
||||||
'validate_cert' => true,
|
'validate_cert' => false,
|
||||||
'username' => $email,
|
'username' => $email,
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
'protocol' => 'imap'
|
'protocol' => 'imap'
|
||||||
@@ -320,5 +320,47 @@ class AccountController extends Controller
|
|||||||
return view('accounts.view', compact('account', 'browser'));
|
return view('accounts.view', compact('account', 'browser'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function proxy()
|
||||||
|
{
|
||||||
|
// Téléchargement de la liste
|
||||||
|
$response = Http::get('https://proxy.webshare.io/api/v2/proxy/list/download/zmfyvsfdtcijphrsokpjbbxdxrvtxynlkmtxpwsd/-/any/username/direct/-/');
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
return response()->json(['error' => 'Impossible de télécharger la liste'], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parsing de la liste
|
||||||
|
$proxyList = explode("\n", trim($response->body()));
|
||||||
|
|
||||||
|
// Récupérer les 100 premiers comptes dans l'ordre
|
||||||
|
$accounts = Account::orderBy('id')->take(100)->get();
|
||||||
|
|
||||||
|
// Vérifier si le nombre de proxies correspond au nombre de comptes
|
||||||
|
if (count($proxyList) < 100) {
|
||||||
|
return response()->json(['error' => 'Le fichier ne contient pas suffisamment de proxies'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mettre à jour chaque compte avec le proxy correspondant
|
||||||
|
foreach ($accounts as $index => $account) {
|
||||||
|
$proxyParts = explode(':', $proxyList[$index]);
|
||||||
|
|
||||||
|
if (count($proxyParts) !== 4) {
|
||||||
|
return response()->json(['error' => "Format incorrect sur la ligne ".$index + 1], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
[$ip, $port, $user, $password] = $proxyParts;
|
||||||
|
|
||||||
|
// Construire l'URL proxy
|
||||||
|
$proxyUrl = "http://{$user}:{$password}@{$ip}:{$port}";
|
||||||
|
$proxyLine = preg_replace('/\s+/', '', $proxyUrl);
|
||||||
|
|
||||||
|
// Mettre à jour la base de données
|
||||||
|
$account->proxy = $proxyLine;
|
||||||
|
$account->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['success' => 'Les 100 premiers proxies ont été mis à jour avec succès']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,12 +53,12 @@ class Account extends Resource
|
|||||||
Boolean::make('Enable'),
|
Boolean::make('Enable'),
|
||||||
Text::make('Name'),
|
Text::make('Name'),
|
||||||
Text::make('Password'),
|
Text::make('Password'),
|
||||||
Text::make('Rambler Email')->readonly(),
|
Text::make('Rambler Email'),
|
||||||
Text::make('Rambler Password')->readonly()->hideFromIndex(),
|
Text::make('Rambler Password')->hideFromIndex(),
|
||||||
Text::make('Auth Token')->hideFromIndex(),
|
Text::make('Auth Token')->hideFromIndex(),
|
||||||
Text::make('Oauth Token')->readonly()->hideFromIndex(),
|
Text::make('Oauth Token')->hideFromIndex(),
|
||||||
Text::make('Oauth Token Secret')->readonly()->hideFromIndex(),
|
Text::make('Oauth Token Secret')->hideFromIndex(),
|
||||||
Text::make('Known Device Token')->readonly()->hideFromIndex(),
|
Text::make('Known Device Token')->hideFromIndex(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user