714 lines
30 KiB
PHP
714 lines
30 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Exception;
|
|
use GuzzleHttp\Client;
|
|
use GuzzleHttp\HandlerStack;
|
|
use GuzzleHttp\Subscriber\Oauth\Oauth1;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class APIController extends Controller
|
|
{
|
|
protected $twitterHeaders = [
|
|
'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-client-language' => 'en-US',
|
|
'x-twitter-client-version' => '10.46.0-release.0',
|
|
'x-twitter-client' => 'TwitterAndroid',
|
|
'x-twitter-api-version' => '5',
|
|
'x-twitter-active-user' => 'yes',
|
|
'os-version' => '30',
|
|
'x-attest-token' => 'no_token',
|
|
];
|
|
|
|
public function retweet($user, $tweetid)
|
|
{
|
|
$stack = $this->Oauth1($user);
|
|
|
|
// Créer le client Guzzle avec le handler stack
|
|
$client = new Client([
|
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
|
'handler' => $stack,
|
|
'proxy' => [
|
|
'http' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
$params = [
|
|
"features" => json_encode([
|
|
"longform_notetweets_inline_media_enabled" => true,
|
|
"super_follow_badge_privacy_enabled" => true,
|
|
"longform_notetweets_rich_text_read_enabled" => true,
|
|
"super_follow_user_api_enabled" => true,
|
|
"super_follow_tweet_api_enabled" => true,
|
|
"articles_api_enabled" => true,
|
|
"android_graphql_skip_api_media_color_palette" => true,
|
|
"creator_subscriptions_tweet_preview_api_enabled" => true,
|
|
"freedom_of_speech_not_reach_fetch_enabled" => true,
|
|
"tweetypie_unmention_optimization_enabled" => true,
|
|
"longform_notetweets_consumption_enabled" => true,
|
|
"subscriptions_verification_info_enabled" => true,
|
|
"blue_business_profile_image_shape_enabled" => true,
|
|
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled" => true,
|
|
"immersive_video_status_linkable_timestamps" => true,
|
|
"super_follow_exclusive_tweet_notifications_enabled" => true,
|
|
]),
|
|
"variables" => json_encode([
|
|
"includeTweetImpression" => true,
|
|
"includeHasBirdwatchNotes" => false,
|
|
"includeEditPerspective" => false,
|
|
"tweet_id" => $tweetid,
|
|
"includeEditControl" => true,
|
|
"includeTweetVisibilityNudge" => true,
|
|
])
|
|
];
|
|
|
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
|
$res = $client->post('24zITFB5aD73PxYtmc6pkA/CreateRetweet', [
|
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
|
'auth' => 'oauth',
|
|
'json' => $params
|
|
]);
|
|
|
|
}
|
|
|
|
public function reply($user, $tweetid, $text)
|
|
{
|
|
$stack = $this->Oauth1($user);
|
|
|
|
// Créer le client Guzzle avec le handler stack
|
|
$client = new Client([
|
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
|
'handler' => $stack,
|
|
'proxy' => [
|
|
'http' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
$params = [
|
|
"features" => json_encode([
|
|
"longform_notetweets_inline_media_enabled" => true,
|
|
"super_follow_badge_privacy_enabled" => true,
|
|
"longform_notetweets_rich_text_read_enabled" => true,
|
|
"super_follow_user_api_enabled" => true,
|
|
"super_follow_tweet_api_enabled" => true,
|
|
"articles_api_enabled" => true,
|
|
"android_graphql_skip_api_media_color_palette" => true,
|
|
"creator_subscriptions_tweet_preview_api_enabled" => true,
|
|
"freedom_of_speech_not_reach_fetch_enabled" => true,
|
|
"tweetypie_unmention_optimization_enabled" => true,
|
|
"longform_notetweets_consumption_enabled" => true,
|
|
"subscriptions_verification_info_enabled" => true,
|
|
"blue_business_profile_image_shape_enabled" => true,
|
|
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled" => true,
|
|
"immersive_video_status_linkable_timestamps" => true,
|
|
"super_follow_exclusive_tweet_notifications_enabled" => true
|
|
]),
|
|
"variables" => json_encode([
|
|
"nullcast" => false,
|
|
"includeTweetImpression" => true,
|
|
"includeHasBirdwatchNotes" => false,
|
|
"includeEditPerspective" => false,
|
|
"includeEditControl" => true,
|
|
"batch_compose" => "BatchSubsequent",
|
|
"includeCommunityTweetRelationship" => false,
|
|
"reply" => [
|
|
"exclude_reply_user_ids" => [],
|
|
"in_reply_to_tweet_id" => $tweetid,
|
|
],
|
|
"includeTweetVisibilityNudge" => true,
|
|
"tweet_text" => $text,
|
|
]),
|
|
];
|
|
|
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
|
$res = $client->post('2ambiU1P_BmZ_CZ1yQ8E1Q/CreateTweet', [
|
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
|
'auth' => 'oauth',
|
|
'json' => $params
|
|
]);
|
|
}
|
|
|
|
public function follow($user, $tweetid)
|
|
{
|
|
$stack = $this->Oauth1($user);
|
|
|
|
// Créer le client Guzzle avec le handler stack
|
|
$client = new Client([
|
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
|
'handler' => $stack,
|
|
'proxy' => [
|
|
'http' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
$params = [
|
|
"variables" => [
|
|
"referrer" => "profile",
|
|
"includeTweetImpression" => true,
|
|
"includeHasBirdwatchNotes" => false,
|
|
"isReaderMode" => false,
|
|
"includeEditPerspective" => false,
|
|
"includeEditControl" => true,
|
|
"focalTweetId" => $tweetid,
|
|
"includeCommunityTweetRelationship" => true,
|
|
"includeTweetVisibilityNudge" => true,
|
|
],
|
|
"features" => [
|
|
"longform_notetweets_inline_media_enabled" => true,
|
|
"super_follow_badge_privacy_enabled" => true,
|
|
"longform_notetweets_rich_text_read_enabled" => true,
|
|
"super_follow_user_api_enabled" => true,
|
|
"unified_cards_ad_metadata_container_dynamic_card_content_query_enabled" => true,
|
|
"super_follow_tweet_api_enabled" => true,
|
|
"articles_api_enabled" => true,
|
|
"android_graphql_skip_api_media_color_palette" => true,
|
|
"creator_subscriptions_tweet_preview_api_enabled" => true,
|
|
"freedom_of_speech_not_reach_fetch_enabled" => true,
|
|
"tweetypie_unmention_optimization_enabled" => true,
|
|
"longform_notetweets_consumption_enabled" => true,
|
|
"subscriptions_verification_info_enabled" => true,
|
|
"blue_business_profile_image_shape_enabled" => true,
|
|
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled" => true,
|
|
"immersive_video_status_linkable_timestamps" => true,
|
|
"super_follow_exclusive_tweet_notifications_enabled" => true,
|
|
],
|
|
];
|
|
|
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
|
$res = $client->get('NAHO_rBo3Yf1hBXROp7Msg/ConversationTimelineV2', [
|
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
|
'auth' => 'oauth',
|
|
'json' => $params
|
|
]);
|
|
|
|
// Décoder le JSON en tableau PHP
|
|
$data = json_decode($res->getBody()->getContents(), true);
|
|
|
|
// Initialiser un tableau pour stocker les IDs
|
|
$userMentionIds = [];
|
|
|
|
// Extraire les IDs des mentions uniquement pour la première instruction et la première entrée
|
|
if (isset($data['data']['timeline_response']['instructions'][0]['entries'][0]['content']['content']['tweetResult']['result']['legacy']['entities']['user_mentions'])) {
|
|
$userMentionIds[] = $data['data']['timeline_response']['instructions'][0]['entries'][0]['content']['content']['tweetResult']['result']['legacy']['user_id_str'];
|
|
$mentions = $data['data']['timeline_response']['instructions'][0]['entries'][0]['content']['content']['tweetResult']['result']['legacy']['entities']['user_mentions'];
|
|
foreach ($mentions as $mention) {
|
|
$userMentionIds[] = $mention['id_str'];
|
|
}
|
|
}
|
|
|
|
$userMentionIds = array_unique($userMentionIds);
|
|
|
|
foreach ($userMentionIds as $mention) {
|
|
$stack = $this->Oauth1($user);
|
|
|
|
$client = new Client([
|
|
'base_uri' => 'https://api.twitter.com/1.1/',
|
|
'handler' => $stack,
|
|
'proxy' => [
|
|
'http' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
|
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
|
$res = $client->post('friendships/create.json?user_id='.$mention.'&ext=mediaRestrictions,altText,mediaStats,mediaColor,info360,highlightedLabel,unmentionInfo,editControl,previousCounts,limitedActionResults,superFollowMetadata&send_error_codes=true&handles_challenges=1', [
|
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
|
'auth' => 'oauth' // Assurez-vous que l'authentification OAuth est incluse
|
|
]);
|
|
sleep(30);
|
|
}
|
|
}
|
|
|
|
public function like($user, $tweetid)
|
|
{
|
|
$stack = $this->Oauth1($user);
|
|
|
|
// Créer le client Guzzle avec le handler stack
|
|
$client = new Client([
|
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
|
'handler' => $stack,
|
|
'proxy' => [
|
|
'http' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
$params = [
|
|
"variables" => [
|
|
"includeTweetImpression" => true,
|
|
"includeHasBirdwatchNotes" => false,
|
|
"includeEditPerspective" => false,
|
|
"tweet_id" => $tweetid,
|
|
"includeEditControl" => true
|
|
]
|
|
];
|
|
|
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
|
$res = $client->post('lI07N6Otwv1PhnEgXILM7A/FavoriteTweet', [
|
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
|
'auth' => 'oauth',
|
|
'json' => $params
|
|
]);
|
|
|
|
}
|
|
public function tweet($user, $text)
|
|
{
|
|
$stack = $this->Oauth1($user);
|
|
|
|
// Créer le client Guzzle avec le handler stack
|
|
$client = new Client([
|
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
|
'handler' => $stack,
|
|
'proxy' => [
|
|
'http' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
$params = [
|
|
"features" => [
|
|
"longform_notetweets_inline_media_enabled" => true,
|
|
"super_follow_badge_privacy_enabled" => true,
|
|
"longform_notetweets_rich_text_read_enabled" => true,
|
|
"super_follow_user_api_enabled" => true,
|
|
"super_follow_tweet_api_enabled" => true,
|
|
"articles_api_enabled" => true,
|
|
"android_graphql_skip_api_media_color_palette" => true,
|
|
"creator_subscriptions_tweet_preview_api_enabled" => true,
|
|
"freedom_of_speech_not_reach_fetch_enabled" => true,
|
|
"tweetypie_unmention_optimization_enabled" => true,
|
|
"longform_notetweets_consumption_enabled" => true,
|
|
"subscriptions_verification_info_enabled" => true,
|
|
"blue_business_profile_image_shape_enabled" => true,
|
|
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled" => true,
|
|
"immersive_video_status_linkable_timestamps" => true,
|
|
"super_follow_exclusive_tweet_notifications_enabled" => true
|
|
],
|
|
"variables" => [
|
|
"nullcast" => false,
|
|
"includeTweetImpression" => true,
|
|
"includeHasBirdwatchNotes" => false,
|
|
"includeEditPerspective" => false,
|
|
"includeEditControl" => true,
|
|
"includeCommunityTweetRelationship" => false,
|
|
"includeTweetVisibilityNudge" => true,
|
|
"tweet_text" => $text
|
|
]
|
|
];
|
|
|
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
|
$res = $client->post('2ambiU1P_BmZ_CZ1yQ8E1Q/CreateTweet', [
|
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
|
'auth' => 'oauth',
|
|
'json' => $params
|
|
]);
|
|
|
|
}
|
|
|
|
public function unread($user)
|
|
{
|
|
try{
|
|
$stack = $this->Oauth1($user);
|
|
|
|
// Créer le client Guzzle avec le handler stack
|
|
$client = new Client([
|
|
'base_uri' => 'https://api.twitter.com/2/',
|
|
'handler' => $stack,
|
|
'proxy' => [
|
|
'http' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
|
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
|
$res = $client->get('badge_count/badge_count.json?supports_ntab_urt=true', [
|
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
|
'auth' => 'oauth' // Assurez-vous que l'authentification OAuth est incluse
|
|
]);
|
|
|
|
|
|
$unred = json_decode($res->getBody()->getContents(), true);
|
|
|
|
// L'URL des deux liens
|
|
$url = 'https://myx.ovh/accounts/'.$user->id;
|
|
|
|
$keyboard = [
|
|
'inline_keyboard' => [
|
|
[
|
|
['text' => 'Cliquez ici pour plus d\'infos', 'url' => $url]
|
|
]
|
|
]
|
|
];
|
|
|
|
// Convertir le tableau de clavier en JSON
|
|
$keyboardJson = json_encode($keyboard);
|
|
|
|
if ($unred['dm_unread_count'] > 0) {
|
|
|
|
$text = "Un nouveau message pour le compte ".$user->name;
|
|
Http::get('https://api.telegram.org/bot6784810105:AAEq3emnkRwdyvCLC-iqdIjVJ2Ke6HwwGjg/sendMessage', [
|
|
'chat_id' => '1970698501', // Remplacez par votre chat_id
|
|
'text' => $text,
|
|
'reply_markup' => $keyboardJson
|
|
]);
|
|
|
|
|
|
}elseif ($unred['ntab_unread_count'] > 1) {
|
|
|
|
$text = "Une notification pour le compte ".$user->name;
|
|
Http::get('https://api.telegram.org/bot6784810105:AAEq3emnkRwdyvCLC-iqdIjVJ2Ke6HwwGjg/sendMessage', [
|
|
'chat_id' => '1970698501', // Remplacez par votre chat_id
|
|
'text' => $text,
|
|
'reply_markup' => $keyboardJson
|
|
]);
|
|
|
|
}
|
|
}catch (Exception $exception){
|
|
$text = "Le compte Twitter " . $user->name . " : " . $exception->getMessage();
|
|
|
|
// L'URL des deux liens
|
|
$url = 'https://myx.ovh/accounts/'.$user->id;
|
|
|
|
$keyboard = [
|
|
'inline_keyboard' => [
|
|
[
|
|
['text' => 'Cliquez ici pour plus d\'infos', 'url' => $url]
|
|
]
|
|
]
|
|
];
|
|
|
|
// Convertir le tableau de clavier en JSON
|
|
$keyboardJson = json_encode($keyboard);
|
|
|
|
// Envoyer le message avec les deux boutons
|
|
Http::get('https://api.telegram.org/bot6784810105:AAEq3emnkRwdyvCLC-iqdIjVJ2Ke6HwwGjg/sendMessage', [
|
|
'chat_id' => '1970698501', // Remplacez par votre chat_id
|
|
'text' => $text,
|
|
'reply_markup' => $keyboardJson
|
|
]);
|
|
}
|
|
|
|
}
|
|
|
|
public function getweets($user, $tweetid)
|
|
{
|
|
$stack = $this->Oauth1($user);
|
|
|
|
// Créer le client Guzzle avec le handler stack
|
|
$client = new Client([
|
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
|
'handler' => $stack,
|
|
'proxy' => [
|
|
'http' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
$params = [
|
|
'variables' => [
|
|
'referrer' => 'home',
|
|
'includeTweetImpression' => true,
|
|
'includeHasBirdwatchNotes' => false,
|
|
'isReaderMode' => false,
|
|
'includeEditPerspective' => false,
|
|
'includeEditControl' => true,
|
|
'focalTweetId' => $tweetid,
|
|
'includeCommunityTweetRelationship' => true,
|
|
'includeTweetVisibilityNudge' => true
|
|
],
|
|
'features' => [
|
|
'longform_notetweets_inline_media_enabled' => true,
|
|
'super_follow_badge_privacy_enabled' => true,
|
|
'longform_notetweets_rich_text_read_enabled' => true,
|
|
'super_follow_user_api_enabled' => true,
|
|
'unified_cards_ad_metadata_container_dynamic_card_content_query_enabled' => true,
|
|
'super_follow_tweet_api_enabled' => true,
|
|
'articles_api_enabled' => true,
|
|
'android_graphql_skip_api_media_color_palette' => true,
|
|
'creator_subscriptions_tweet_preview_api_enabled' => true,
|
|
'freedom_of_speech_not_reach_fetch_enabled' => true,
|
|
'tweetypie_unmention_optimization_enabled' => true,
|
|
'longform_notetweets_consumption_enabled' => true,
|
|
'subscriptions_verification_info_enabled' => true,
|
|
'blue_business_profile_image_shape_enabled' => true,
|
|
'tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled' => true,
|
|
'immersive_video_status_linkable_timestamps' => true,
|
|
'super_follow_exclusive_tweet_notifications_enabled' => true
|
|
]
|
|
];
|
|
|
|
|
|
// Initialisation du tableau des tweets à l'extérieur de la boucle
|
|
$tweets = [];
|
|
|
|
// Initialisation du curseur à null avant le début de la boucle
|
|
$cursor = null;
|
|
|
|
// Nombre de tours
|
|
$maxLoops = 5;
|
|
|
|
// Boucle pour exécuter 5 tours
|
|
for ($loop = 1; $loop <= $maxLoops; $loop++) {
|
|
// Si ce n'est pas le premier tour, ajouter le curseur dans les paramètres
|
|
if ($loop > 1 && $cursor !== null) {
|
|
$params['variables']['cursor'] = $cursor; // Ajouter la valeur du curseur au paramètre
|
|
}
|
|
|
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
|
$res = $client->get('NAHO_rBo3Yf1hBXROp7Msg/ConversationTimelineV2', [
|
|
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
|
'auth' => 'oauth',
|
|
'json' => $params
|
|
]);
|
|
|
|
// Décoder la réponse
|
|
$data = json_decode($res->getBody()->getContents(), true);
|
|
|
|
// Réinitialiser le curseur à chaque tour
|
|
$cursor = null;
|
|
|
|
// Navigation dans le tableau pour extraire les données
|
|
$instructions = $data['data']['timeline_response']['instructions'] ?? [];
|
|
foreach ($instructions as $instruction) {
|
|
// Vérification si l'instruction est de type 'TimelineAddEntries'
|
|
if ($instruction['__typename'] === 'TimelineAddEntries') {
|
|
// Parcours des entrées (entries) dans chaque instruction
|
|
foreach ($instruction['entries'] as $entry) {
|
|
// Vérifier si l'entrée contient un tweet
|
|
if (isset($entry['content']['items'][0]['item']['content']['tweetResult'])) {
|
|
// Récupérer le texte complet du tweet
|
|
$tweet = $entry['content']['items'][0]['item']['content']['tweetResult']['result']['legacy']['full_text'] ?? '';
|
|
// Supprimer les hashtags
|
|
$tweet = preg_replace('/#\w+\s?/', '', $tweet);
|
|
|
|
// Supprimer les tags
|
|
$tweet = preg_replace('/@\w+\s?/', '', $tweet);
|
|
|
|
$tweets[] = $tweet;
|
|
}
|
|
|
|
// Vérifier si l'entrée contient un curseur, dont l'entryId commence par 'cursor-bottom'
|
|
if (isset($entry['content']['content']['value']) && str_starts_with($entry['entryId'], 'cursor-bottom')) {
|
|
// Récupérer la valeur du curseur
|
|
$cursor = $entry['content']['content']['value'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return $tweets;
|
|
}
|
|
|
|
public function newstweet($user)
|
|
{
|
|
|
|
$stack = $this->Oauth1($user);
|
|
|
|
$newArray = [];
|
|
$existingConversationIds = []; // Tableau pour suivre les IDs de conversation déjà vus
|
|
|
|
$search = [
|
|
'1177177387475378177',
|
|
'1491472590891888645',
|
|
'1642170070351638534',
|
|
'1533089245576970240',
|
|
'1493931667731406848',
|
|
'1513789977938776070',
|
|
'1531291630040391682',
|
|
'1741188576845455676',
|
|
'1191374346473873409',
|
|
'55882909'
|
|
];
|
|
|
|
foreach ($search as $list) {
|
|
// Créer le client Guzzle avec le handler stack
|
|
$client = new Client([
|
|
'base_uri' => 'https://api.twitter.com/graphql/',
|
|
'handler' => $stack,
|
|
'proxy' => [
|
|
'http' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
// Ajouter les en-têtes personnalisés
|
|
$headers = [
|
|
'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-client-language' => 'en-US',
|
|
'x-twitter-client-version' => '10.46.0-release.0',
|
|
'x-twitter-client' => 'TwitterAndroid',
|
|
'x-twitter-api-version' => '5',
|
|
'x-twitter-active-user' => 'yes',
|
|
'os-version' => '30',
|
|
'x-attest-token' => 'no_token',
|
|
];
|
|
|
|
$params = [
|
|
"features" => [
|
|
"longform_notetweets_inline_media_enabled" => true,
|
|
"super_follow_badge_privacy_enabled" => true,
|
|
"longform_notetweets_rich_text_read_enabled" => true,
|
|
"super_follow_user_api_enabled" => true,
|
|
"unified_cards_ad_metadata_container_dynamic_card_content_query_enabled" => true,
|
|
"super_follow_tweet_api_enabled" => true,
|
|
"articles_api_enabled" => true,
|
|
"android_graphql_skip_api_media_color_palette" => true,
|
|
"creator_subscriptions_tweet_preview_api_enabled" => true,
|
|
"freedom_of_speech_not_reach_fetch_enabled" => true,
|
|
"tweetypie_unmention_optimization_enabled" => true,
|
|
"longform_notetweets_consumption_enabled" => true,
|
|
"subscriptions_verification_info_enabled" => true,
|
|
"blue_business_profile_image_shape_enabled" => true,
|
|
"tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled" => true,
|
|
"immersive_video_status_linkable_timestamps" => true,
|
|
"super_follow_exclusive_tweet_notifications_enabled" => true,
|
|
],
|
|
"variables" => [
|
|
"includeTweetImpression" => true,
|
|
"includeHasBirdwatchNotes" => false,
|
|
"includeEditPerspective" => false,
|
|
"includeEditControl" => true,
|
|
"rest_id" => $list,
|
|
"includeTweetVisibilityNudge" => true,
|
|
]
|
|
];
|
|
|
|
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
|
$res = $client->get('LgWGBhvCVo5vHMsokMdEWA/ListTimeline', [
|
|
'headers' => $headers, // Ajouter les en-têtes ici
|
|
'auth' => 'oauth',
|
|
'json' => $params
|
|
]);
|
|
|
|
$data = json_decode($res->getBody()->getContents(), true);
|
|
|
|
$tweets = $data['data']['list']['timeline_response']['timeline']['instructions'][0]['entries'];
|
|
|
|
foreach ($tweets as $item) {
|
|
if (isset($item['content']['content']['tweetResult']['result']['legacy']['retweeted_status_result'])) {
|
|
// Tweet retweeté, ignorer
|
|
} elseif (isset($item['content']['content']['tweetResult']['result']['legacy'])) {
|
|
$news = $item['content']['content']['tweetResult']['result']['legacy'];
|
|
$conversationId = $news['conversation_id_str'];
|
|
|
|
// Vérifier si le tweet a déjà été ajouté en fonction de l'ID de la conversation
|
|
if (in_array($conversationId, $existingConversationIds)) {
|
|
continue; // Si le tweet existe déjà, passer à l'itération suivante
|
|
}
|
|
|
|
if (str_contains(strtolower($news['full_text']), ' rt ')) {
|
|
continue; // Si le texte contient "rt", passer à l'itération suivante
|
|
}
|
|
|
|
// Ajouter l'ID de conversation à la liste des IDs déjà vus
|
|
$existingConversationIds[] = $conversationId;
|
|
|
|
// Ajouter le tweet si le nombre de réponses, de favoris ou de retweets est supérieur à 50
|
|
if ($news['reply_count'] > 10 || $news['favorite_count'] > 10 || $news['retweet_count'] > 10) {
|
|
$newArray[] = $news;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Cache::put('news', $newArray, 1800);
|
|
|
|
return $newArray;
|
|
|
|
}
|
|
|
|
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' => $user->proxy,
|
|
]
|
|
]);
|
|
|
|
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){
|
|
// Vérifier si l'exception contient le message spécifique
|
|
if (str_contains($e->getMessage(), 'To protect our users from spam and other malicious activity')) {
|
|
// Action spécifique si le message correspond
|
|
$text = "Le compte ".$user->name.' a besoin d\'une reoslution arkos.';
|
|
Http::get('https://api.telegram.org/bot6784810105:AAEq3emnkRwdyvCLC-iqdIjVJ2Ke6HwwGjg/sendMessage', [
|
|
'chat_id' => '1970698501', // Remplacez par votre chat_id
|
|
'text' => $text,
|
|
]);
|
|
} else {
|
|
// Continuer avec les autres actions si l'exception ne correspond pas
|
|
$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',
|
|
'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',
|
|
'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',
|
|
'text' => $text,
|
|
]);
|
|
}
|
|
$stack = $this->Oauth1($user);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private function Oauth1($user)
|
|
{
|
|
// Créer le stack pour gérer l'authentification OAuth
|
|
$stack = HandlerStack::create();
|
|
|
|
$middleware = new Oauth1([
|
|
'consumer_key' => '3nVuSoBZnx6U4vzUxf5w',
|
|
'consumer_secret' => 'Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys',
|
|
'token' => $user->oauth_token,
|
|
'token_secret' => $user->oauth_token_secret
|
|
]);
|
|
|
|
$stack->push($middleware);
|
|
|
|
return $stack;
|
|
}
|
|
|
|
}
|