Ошибка 400 не правильный client id twitch api
Когда я запустил код выдало это {"error":"Bad Request","status":400,"message":"The "Client-ID" header is invalid."} клиент айди twitch api у меня правильный.
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Leaf.xNet;
using OutherParam;
using StringHelper;
using System.IO;
using System.Net;
using System.Net.Http;
namespace TwitchBot
{
public class TwitchBot
{
public int gen;
public static string channelTwitch;
public static int Generation;
public static int countWorkThreads;
public static int time;
string[] proxyList = File.ReadAllLines("C:\\Users\\GLEBHAS\\Desktop\\App\\TwitchBot\\proxy.txt");
public bool Working() => this.gen != 0;
public TwitchBot(int gen)
{
this.gen = gen;
}
public async Task Loop1()
{
long totalSentBytes = 0;
long totalReceivedBytes = 0;
string token = "";
string sig = "";
string usher = "";
string videolink = "";
foreach (var proxyInfo in proxyList)
{
string[] proxyParts = proxyInfo.Split(':');
string proxyAddress = proxyParts[0];
int proxyPort = int.Parse(proxyParts[1]);
try
{
using (HttpRequest reqFull = new HttpRequest())
{
HttpClientHandler handler = new HttpClientHandler();
//handler.Proxy = new WebProxy($"http://{proxyAddress}:{proxyPort}");
HttpClient client = new HttpClient(handler);
//reqFull.IgnoreProtocolErrors = true;
reqFull.KeepAlive = false;
reqFull["Client-ID"] = "s92hr2ftp68dka0a6mk6gh1dwrr90h"; //b31o4btkqth5bzbvr9ub2ovr79umhh
reqFull[HttpHeader.UserAgent] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.58";
reqFull.EnableEncodingContent = false;
var requestParams = new RequestParams();
requestParams["Content-Type"] = "application/json";
requestParams["Body"] = "{\"operationName\":\"zapros\", \"streamId\": \"948451119\"}";
string apiString = reqFull.Post("https://gql.twitch.tv/gql").ToString();
token = apiString;
sig = apiString;
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
Console.WriteLine($"Stack Trace: {ex.StackTrace}");
// Add more detailed logging if needed
continue;
}
while (this.Working())
{
try
{
using (HttpRequest reqFull1 = new HttpRequest())
{
reqFull1.KeepAlive = false;
reqFull1[HttpHeader.Accept] = "application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain";
reqFull1[HttpHeader.Referer] = $"https://twitch.tv/leo__king";
reqFull1[HttpHeader.UserAgent] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36";
reqFull1.EnableEncodingContent = false;
usher = reqFull1.Get("https://usher.ttvnw.net/api/leo__king/hls/" + ".m3u8?acmb=e30=&allow_source=true&fast_bread=true&p=" + new Random().Next(1111111, 9999999).ToString() + "&player_backend=mediaplayer&playlist_include_framerate=true&reassignments_supported=true&sig=" + sig + "&supported_codecs=avc1&token=" + token + "&cdm=wv&player_version=1.18.0").ToString();
videolink = "https://video-weaver" + usher; // Simplified for brevity
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
break;
}
if (this.Working())
{
try
{
using (HttpRequest reqFull2 = new HttpRequest())
{
reqFull2.KeepAlive = false;
reqFull2[HttpHeader.Accept] = "application/x-mpegURL, application/vnd.apple.mpegurl, application/json, text/plain";
reqFull2[HttpHeader.Referer] = "https://twitch.tv/leo__king";
reqFull2[HttpHeader.UserAgent] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36";
reqFull2.EnableEncodingContent = false;
reqFull2.Head(videolink);
await Task.Delay(1000);
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
//reqFull1 = (HttpRequest)null;
}
//reqFull = (HttpRequest)null;
}
token = null;
sig = null;
usher = null;
videolink = null;
}
public static void postLog(string channel)
{
try
{
HttpRequest httpRequest = new HttpRequest();
httpRequest.AddHeader(HttpHeader.Referer, "https://twitch.tv/leo__king");
httpRequest.AddHeader(HttpHeader.ContentType, "application/x-www-form-urlencoded");
string response = httpRequest.Post("https://twitch.tv/log").ToString();
Console.WriteLine(response);
}
catch (Exception ex)
{
Console.WriteLine($"Error in postLog: {ex.Message}");
}
catch
{
Process.GetCurrentProcess().Kill();
}
}
}
public class Program
{
public static void Main()
{
// Instantiate and run TwitchBot here
TwitchBot bot = new TwitchBot(1);
Task.Run(async () => await bot.Loop1());
Console.ReadLine();
}
}
}