Recherche des tweets de réponse avec l'API Tweeter
This commit is contained in:
557
app/Http/Controllers/APIController.php
Normal file
557
app/Http/Controllers/APIController.php
Normal file
@@ -0,0 +1,557 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
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' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
||||
]
|
||||
]);
|
||||
|
||||
$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
|
||||
]);
|
||||
|
||||
if ($res->getStatusCode() != 200) {
|
||||
$text = "Le compte twitter ".$user->Name." a été désactivé";
|
||||
|
||||
Http::get('https://api.telegram.org/bot7036172799:AAEVZXHu4SL64VWN5c0AxM1BVxvB0-k6lT0/sendMessage?chat_id=1970698501&text=' . urlencode($text));
|
||||
|
||||
$user->enabled = false;
|
||||
$user->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
||||
]
|
||||
]);
|
||||
|
||||
$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
|
||||
]);
|
||||
|
||||
if ($res->getStatusCode() != 200) {
|
||||
$text = "Le compte twitter ".$user->Name." a été désactivé";
|
||||
|
||||
Http::get('https://api.telegram.org/bot7036172799:AAEVZXHu4SL64VWN5c0AxM1BVxvB0-k6lT0/sendMessage?chat_id=1970698501&text=' . urlencode($text));
|
||||
|
||||
$user->enabled = false;
|
||||
$user->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function follow($user, $follow)
|
||||
{
|
||||
$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',
|
||||
]
|
||||
]);
|
||||
|
||||
|
||||
// Effectuer la requête POST avec OAuth et les en-têtes personnalisés
|
||||
$res = $client->post('friendships/create.json?screen_name='.$follow.'&follow=true', [
|
||||
'headers' => $this->twitterHeaders, // Ajouter les en-têtes ici
|
||||
'auth' => 'oauth' // Assurez-vous que l'authentification OAuth est incluse
|
||||
]);
|
||||
|
||||
if ($res->getStatusCode() != 200) {
|
||||
$text = "Le compte twitter ".$user->Name." a été désactivé";
|
||||
|
||||
Http::get('https://api.telegram.org/bot7036172799:AAEVZXHu4SL64VWN5c0AxM1BVxvB0-k6lT0/sendMessage?chat_id=1970698501&text=' . urlencode($text));
|
||||
|
||||
$user->enabled = false;
|
||||
$user->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
||||
]
|
||||
]);
|
||||
|
||||
$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' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
||||
]
|
||||
]);
|
||||
|
||||
$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)
|
||||
{
|
||||
$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' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
||||
]
|
||||
]);
|
||||
|
||||
|
||||
// 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/nova/resources/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'] > 0) {
|
||||
|
||||
$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
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
||||
]
|
||||
]);
|
||||
|
||||
$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 = 10;
|
||||
|
||||
// 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
|
||||
$tweets[] = $entry['content']['items'][0]['item']['content']['tweetResult']['result']['legacy']['full_text'] ?? '';
|
||||
}
|
||||
|
||||
// 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'
|
||||
];
|
||||
|
||||
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' => 'http://xtjnmwvl-'.$user->id.':lp7iv1lq9glu@p.webshare.io:80',
|
||||
]
|
||||
]);
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user