❤️❤️? ¿Conectar a Tiktok en vivo en 3 líneas ? ❤️❤️
Una biblioteca de Java inspirada en Tiktoklive y Tiktoklivesharp. Úselo para recibir eventos de transmisión en vivo como comentarios y regalos en tiempo real desde Tiktok Live conectando al servicio interno de Push Push de Tiktok. La biblioteca incluye un envoltorio que se conecta al servicio de transmisión web utilizando solo el nombre de usuario ( uniqueId ). Esto le permite conectarse a su propio chat en vivo, así como al chat en vivo de otros streamers. No se requieren credenciales. Se pueden rastrear eventos como miembros que se unen, regalos, suscripciones, espectadores, siguen, acciones, preguntas, me gusta y batallas.
Únase a la discordia de soporte y visite el canal #java-support para obtener preguntas, contribuciones e ideas. Siéntase libre de hacer solicitudes de extracción con características, correcciones, etc. faltantes
¿Prefieres otros lenguajes de programación?
Nota: Esta no es una API oficial. Es un proyecto de ingeniería inversa.
Aturdir
< repositories >
< repository >
< id >jitpack.io</ id >
< url >https://jitpack.io</ url >
</ repository >
</ repositories >
< dependencies >
< dependency >
< groupId >com.github.jwdeveloper.TikTok-Live-Java</ groupId >
< artifactId >Client</ artifactId >
< version >1.8.13-Release</ version >
< scope >compile</ scope >
</ dependency >
</ dependencies >Graduarse
dependencyResolutionManagement {
repositoriesMode . set( RepositoriesMode . FAIL_ON_PROJECT_REPOS )
repositories {
mavenCentral()
maven { url ' https://jitpack.io ' }
}
}
dependencies {
implementation ' com.github.jwdeveloper.TikTok-Live-Java:Client:1.8.13-Release '
} TikTokLive . newClient ( "bangbetmenygy" )
. onGift (( liveClient , event ) ->
{
String message = switch ( event . getGift ()) {
case ROSE -> "ROSE!" ;
case GG -> "GOOD GAME" ;
case TIKTOK -> "Ye" ;
case CORGI -> "Nice gift" ;
default -> "Thank you for " + event . getGift (). getName ();
};
System . out . println ( event . getUser (). getProfileName () + " sends " + message );
})
. onGiftCombo (( liveClient , event ) ->
{
System . out . println ( event . getComboState ()+ " " + event . getCombo () + " " + event . getGift (). getName ());
})
. onRoomInfo (( liveClient , event ) ->
{
var roomInfo = event . getRoomInfo ();
System . out . println ( "Room Id: " + roomInfo . getRoomId ());
System . out . println ( "Likes: " + roomInfo . getLikesCount ());
System . out . println ( "Viewers: " + roomInfo . getViewersCount ());
})
. onJoin (( liveClient , event ) ->
{
System . out . println ( event . getUser (). getProfileName () + "Hello on my stream! " );
})
. onConnected (( liveClient , event ) ->
{
System . out . println ( "Connected to live " );
})
. onError (( liveClient , event ) ->
{
System . out . println ( "Error! " + event . getException (). getMessage ());
})
. buildAndConnect (); TikTokLive . newClient ( "bangbetmenygy" )
. configure (( settings ) ->
{
settings . setHostName ( "bangbetmenygy" ); // This method is useful in case you want change hostname later
settings . setClientLanguage ( "en" ); // Language
settings . setTimeout ( Duration . ofSeconds ( 2 )); // Connection timeout
settings . setLogLevel ( Level . ALL ); // Log level
settings . setPrintToConsole ( true ); // Printing all logs to console even if log level is Level.OFF
settings . setRetryOnConnectionFailure ( true ); // Reconnecting if TikTok user is offline
settings . setRetryConnectionTimeout ( Duration . ofSeconds ( 1 )); // Timeout before next reconnection
//Optional: Sometimes not every message from chat are send to TikTokLiveJava to fix this issue you can set sessionId
// documentation how to obtain sessionId https://github.com/isaackogan/TikTok-Live-Connector#send-chat-messages
settings . setSessionId ( "86c3c8bf4b17ebb2d74bb7fa66fd0000" );
//Optional:
//RoomId can be used as an override if you're having issues with HostId.
//You can find it in the HTML for the livestream-page
settings . setRoomId ( "XXXXXXXXXXXXXXXXX" );
})
. buildAndConnect ();
// Control :
Mensaje :
Depuración :
TikTokLive . newClient ( "host-name" )
. onReconnecting (( liveClient , event ) ->
{
})
. buildAndConnect ();Evento de error general. Deberías manejar esto.
TikTokLive . newClient ( "host-name" )
. onError (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cuando la conexión se establece con éxito.
TikTokLive . newClient ( "host-name" )
. onConnected (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cuando la conexión se desconecta. En ese caso, puede llamar a Connect () nuevamente para tener una lógica de reconexión. Tenga en cuenta que debe esperar un poco antes de intentar una reconexión para evitar ser limitado por la velocidad.
TikTokLive . newClient ( "host-name" )
. onDisconnected (( liveClient , event ) ->
{
})
. buildAndConnect ();Clase base para todos los eventos
TikTokLive . newClient ( "host-name" )
. onEvent (( liveClient , event ) ->
{
})
. buildAndConnect ();Clase base para todos los eventos
TikTokLive . newClient ( "host-name" )
. onEvent (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cada vez que llega un nuevo comentario de chat.
TikTokLive . newClient ( "host-name" )
. onComment (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cuando Liveroominfo se actualizó como me gusta, espectadores, clasificación ...
TikTokLive . newClient ( "host-name" )
. onRoomInfo (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cuando el usuario envía regalos que no tienen combo (la mayoría de los regalos caros) o si el combo ha terminado
TikTokLive . newClient ( "host-name" )
. onGift (( liveClient , event ) ->
{
})
. buildAndConnect ();Se desencadena cuando un usuario crea una suscripción.
TikTokLive . newClient ( "host-name" )
. onSubscribe (( liveClient , event ) ->
{
})
. buildAndConnect ();Se desencadena cuando un usuario sigue al transmisor. Basado en el evento social.
TikTokLive . newClient ( "host-name" )
. onFollow (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cada vez que se envía el regalo
@See GSALSENDTYPE TIENE 3 estados
Ejemplo cuando el usuario envía regalo con combo
> Combo: 1 -> combostate = gotsendtype.begin
Combo: 4 -> combostate = GSTSENDTYPE.ACTIVE
Combo: 8 -> combostate = GSTSENDTYPE.ACTIVE
Combo: 12 -> combostate = gotsendType.finished
Recuerde que si el comboste está terminado tanto TiktokGiftComboevent como el evento TikTokGiftEvent se activan
TikTokLive . newClient ( "host-name" )
. onGiftCombo (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cuando el host termina la transmisión en vivo. También activará el evento TiktokDisconnectedEvent.
TikTokLive . newClient ( "host-name" )
. onLiveEnded (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cada vez que alguien hace una nueva pregunta a través de la función de la pregunta.
TikTokLive . newClient ( "host-name" )
. onQuestion (( liveClient , event ) ->
{
})
. buildAndConnect ();Se desencadena cuando un usuario comparte la transmisión. Basado en el evento social.
TikTokLive . newClient ( "host-name" )
. onShare (( liveClient , event ) ->
{
})
. buildAndConnect (); TikTokLive . newClient ( "host-name" )
. onLiveUnpaused (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cada vez que un suscriptor envía un emote (pegatina).
TikTokLive . newClient ( "host-name" )
. onEmote (( liveClient , event ) ->
{
})
. buildAndConnect (); TikTokLive . newClient ( "host-name" )
. onJoin (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cuando un espectador envía me gusta al streamer. Para transmisiones con muchos espectadores, este evento no siempre es desencadenado por Tiktok.
TikTokLive . newClient ( "host-name" )
. onLike (( liveClient , event ) ->
{
})
. buildAndConnect (); TikTokLive . newClient ( "host-name" )
. onLivePaused (( liveClient , event ) ->
{
})
. buildAndConnect (); TikTokLive . newClient ( "host-name" )
. onWebsocketResponse (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cada vez que llega un mensaje de transmisión web de ProTobuf. Puede deserializar el objeto binario según el caso de uso.
TikTokLive . newClient ( "host-name" )
. onWebsocketUnhandledMessage (( liveClient , event ) ->
{
})
. buildAndConnect (); TikTokLive . newClient ( "host-name" )
. onHttpResponse (( liveClient , event ) ->
{
})
. buildAndConnect ();Activado cada vez que Tiktok envía datos. Datos entrantes como mensaje ProtoBuf. Puede deserializar el objeto binario según el caso de uso.
TikTokLive . newClient ( "host-name" )
. onWebsocketMessage (( liveClient , event ) ->
{
})
. buildAndConnect ();Lista de extensiones (complementos) a tiktoklivejava que le ahorrará tiempo
/**
*
* Listeners are an alternative way of handling events.
* I would to suggest to use then when logic of handing event
* is more complex
*
*/
public static void main ( String [] args ) throws IOException {
showLogo ();
CustomListener customListener = new CustomListener ();
TikTokLive . newClient ( SimpleExample . TIKTOK_HOSTNAME )
. addListener ( customListener )
. buildAndConnect ();
System . in . read ();
}
/**
*
* Method in TikTokEventListener should meet 4 requirements to be detected
* - must have @TikTokEventHandler annotation
* - must have 2 parameters
* - first parameter must be LiveClient
* - second must be class that extending TikTokEvent
*/
public static class CustomListener {
@ TikTokEventObserver
public void onLike ( LiveClient liveClient , TikTokLikeEvent event ) {
System . out . println ( event . toString ());
}
@ TikTokEventObserver
public void onError ( LiveClient liveClient , TikTokErrorEvent event ) {
// event.getException().printStackTrace();
}
@ TikTokEventObserver
public void onComment ( LiveClient liveClient , TikTokCommentEvent event ) {
var userName = event . getUser (). getName ();
var text = event . getText ();
liveClient . getLogger (). info ( userName + ": " + text );
}
@ TikTokEventObserver
public void onGift ( LiveClient liveClient , TikTokGiftEvent event ) {
var message = switch ( event . getGift ()) {
case ROSE -> "Thanks :)" ;
case APPETIZERS -> ":OO" ;
case APRIL -> ":D" ;
case TIKTOK -> ":P" ;
case CAP -> ":F" ;
default -> ":I" ;
};
liveClient . getLogger (). info ( message );
}
@ TikTokEventHandler
public void onAnyEvent ( LiveClient liveClient , TikTokEvent event ) {
liveClient . getLogger (). info ( event . getClass (). getSimpleName ());
}
}
// Documentación de la biblioteca para colaboradores
¡Tus mejoras son bienvenidas! Siéntase libre de abrir un problema o hacer una solicitud.