Перейти к содержимому
Бунтовые биты

Бунтовые биты

  • Дом
  • Новости
  • Путеводители
  • Видео-гиды
  • Примечания к патчу
  • Сообщить о нарушении
  • Переключить форму поиска

Dinogen Online – How to Use API

Опубликовано 03/08/2023 К БЛТ Без комментариев на Dinogen Online – How to Use API
  • Заголовок: Dinogen Online
  • Дата выпуска:
  • Разработчик:
  • Издатель:
Information about Dinogen Online is still incomplete. Пожалуйста, помогите нам заполнить детали игры, используя это контактная форма.

This guide shows you the basics of using the Dinogen Online API and gives some examples of usages.

Введение

The purpose of this guide is to help you use the Dinogen Online API to create any sort of 3rd party app that will support the Dinogen Community!

API Explanation

The API is used through a web request format. The base address can change from time to time, but it will always be like this: apiAddress/api/getCall?params. An example for getting a player’s data would be этот. If you click on this link you will notice it returns a JSON. All API calls return a JSON. If you are unfamiliar with the JSON style of data storage, проверить W3Schools Explanation. In order to work with this API you will need a basic knowledge of fetching from a web request server, JSON formatting, and JSON manipulation.

Making a fetch call

Once you have all the basic knowledge, its time to make your first fetch call. For the sake of simplicity I am going to give examples via JavaScript. Note that fetching files from web servers might be different depending on the programming language and the platform you are using.

To start a fetch call in JS you will need to start with a async function, вот так:

async function getPlayerData(address, uname) {

}

Note that this function has two parameters, address and uname. address gives the function the current API address (this will be discussed later), while uname gives the function the username of the player whos data you wish to retrieve.

Следующий, let’s add a fetch call and its dependents:

async function getPlayerData(address, uname) {
    fetch(address + 'api/getPlayer?username=' + uname).затем( функция (response) {
        return response.json();
    }).затем(функция (объект) {
        console.log(объект);
        doStuff(объект);
    }).ловить(функция (ошибка) {
        console.error(ошибка);
    });
}

Вау, thats a lot to take in. Lets break it down. Первый, we call the built in JS function “fetch”, with the address we want to fetch from. Notice this address starts with the param “address”, has the string ‘api/getPlayer?username=’ в середине, и “uname” param at the end. That middle part is where the important parts happen. The “api/” is another part of the address that currently isnt in the address.txt file (подробнее об этом позже). “getPlayer” is the name of one of the calls, specifically the one that returns a player data JSON (you can see all of the calls здесь). И “?username=” is one of the parameters required for the call. This is the basic setup for all the fetch calls to the API that you will make.

After that we call 3 different generic functions. The first translates a response into a readable JSON, and returns it to the second generic. The second logs the JSON object (which is basically the same as a JS object), then calls a function with that data, where you do whatever you need to with that data. The final generic catches any errors and logs them to the console.
Now that you have this, its time to make your fetch function work even when the main api address is down.

Accessing the API address

This portion is super simple. We use almost the same function as before:

async function getAddress(uname) {
  fetch('https://xwilkinx.com/data/dinogen/account.txt').затем( функция (response) {
      return response.text();
  }).затем(функция (объект) {
      console.log(объект);
      getPlayerData(Нить(объект), uname);
  }).ловить(функция (ошибка) {
      console.error(ошибка);
  });
}

This time though, we go to a different address, and we translate the response to a string instead, and send this along to the function made earlier. Once this is all complete your system will update the address when a change is made. Now lets move on to doing things with this data.

Doing things with the data

Here is where we will do stuff with the data. Let’s start by filling out the function from before:

function doStuff(данные) {
    var user = document.createElement('h1');
    user.id = "пользователь";
    document.getElementById('dataDiv').appendChild(пользователь);
}

Here we create a element and add it to the DOM. This will display our requested username. Let give it some data:

function doStuff(данные) {
    var user = document.createElement('h1');
    user.id = "пользователь";
    user.innerHTML = data.username;
    document.getElementById('dataDiv').appendChild(пользователь);
}

If you are not familiar with dot notation, in this case it denotes object hierarchy. Например, data.username means that you want the value for the key “имя пользователя”. This is the same as data[‘username’]. Another example is data.data.level. Now we add another layer to the hierarchy. We are asking for the value of the key “данные”, which is another object, and then we ask for the value of the key “уровень” which is a integer. This is the same as data[‘data’][‘level’]. С этим, it is super simple to access all the data in any JSON the API returns, as long as you know what you are grabbing.

Примеры

В настоящее время, there are two examples of usages of the API. The first is a stat checking website[ that is a work in progress, being made by yours truly. The second is a bot on the Dinogen Online discord[, which was made by Justin, the developer of Dinogen Online.

If you have any questions or issues with the API feel free to contact me or Justin on the discord!

Это все, чем мы делимся сегодня для этого. Dinogen Online гид. Это руководство было первоначально создано и написано БЛТ. На случай, если нам не удастся обновить это руководство, вы можете найти последнее обновление, следуя этому связь.

Если вы считаете, что какой-либо контент на этом сайте нарушает ваши права, включая ваши права интеллектуальной собственности, пожалуйста, свяжитесь с нами немедленно, используя нашу контактную форму.
Путеводители Теги:Dinogen Online

Навигация по публикациям

Предыдущий пост: Tyrant Quest 100% Руководство по концовкам
Следующий пост: Pocky & Rocky Reshrined – Roulette Manipulation Guide

Оставить ответ Отменить ответ

Ваш адрес электронной почты не будет опубликован. Обязательные поля отмечены *

  • Заголовок: Dinogen Online
  • Дата выпуска:
  • Разработчик:
  • Издатель:
Information about Dinogen Online is still incomplete. Пожалуйста, помогите нам заполнить детали игры, используя это контактная форма.

Отказ от ответственности

Весь цитируемый контент взят из соответствующих источников.. Если вы считаете, что мы использовали ваш контент без разрешения, обязательно свяжитесь с нами, и мы отнесемся к этому серьезно.
  • О нас
  • Связаться с нами
  • политика конфиденциальности
  • Условия использования

Авторское право © 2025 Бунтовые биты.

Питаться от Пресс-книга новостей Тема WordPress