Correction des différents bugs
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Subscriber\Oauth\Oauth1;
|
||||
@@ -306,60 +307,85 @@ class APIController extends Controller
|
||||
|
||||
public function unread($user)
|
||||
{
|
||||
$stack = $this->Oauth1($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]
|
||||
// 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,
|
||||
]
|
||||
]
|
||||
];
|
||||
]);
|
||||
|
||||
// Convertir le tableau de clavier en JSON
|
||||
$keyboardJson = json_encode($keyboard);
|
||||
|
||||
if ($unred['dm_unread_count'] > 0) {
|
||||
// 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
|
||||
]);
|
||||
|
||||
$text = "Un nouveau message pour le compte ".$user->name;
|
||||
|
||||
$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
|
||||
]);
|
||||
|
||||
|
||||
}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
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user