Giter VIP home page Giter VIP logo

apigames's Introduction

PHP API GAMES v.1.0

API simples para integração com jogos digitais, por exemplo Godot. Ela apresenta recursos para criação de usuário, login, criação de instância de jogos, salvamento, placar e ranking.

PHP 7.4.3 (cli) (built: Jul  5 2021 15:13:35) ( NTS )
Copyright (c) The PHP Group Zend Engine v3.4.0, 
Copyright (c) Zend Technologies with Zend OPcache v7.4.3, 
Copyright (c), by Zend Technologies

Como usar esse conteúdo?

Este conteúdo é livre para uso e distribuição sob a licença (CC BY-SA 4.0).

Se quiser colaborar neste repositório com melhorias ou correções, basta fazer um fork e enviar um PR.

Estrutura da API

+---api
    \class\
        GameModel.php
        PDOConnection.php
        UserModel.php
    game.php
    scripts.sql
    teste.httpd
    user.php

Database

Esta API utiliza o banco de dados MySQL 5, que pode ser alterado a qualquer momento de acordo com a necessidade de uso. O banco de dados deve ser configurado em \class\PDOConnection.php.

Scripts SQL

CREATE DATABASE name;
CREATE TABLE users
(
    id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    name VARCHAR(100) NOT NULL,
    user  VARCHAR(100) NOT NULL,
    password  VARCHAR(100) NOT NULL
);

CREATE TABLE games
(
    id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    user_id INT(11),
    score INT(11)
);

Resources

User

Resource URI Method
NEW http://URI/api/user.php POST

header

{
  "content-type": "application/json"
}

payload

{
  "type": "new",
  "name": "name",
  "user": "username",
  "password": "password"
}

Success

{
  "data": "ok",
  "value": "user_created_successfully"
}

Warnings

{
  "data": "err",
  "value": "invalid_data"
}
{
  "data": "err",
  "value": "user_[...]_exists"
}

Resource URI Method
LOGIN http://URI/api/user.php POST

header

{
  "content-type": "application/json"
}

payload

{
  "type": "login",
  "user": "username",
  "password": "password"
}

Success

{
  "id": 5,
  "user": "username",
  "name": "name",
  "data": "ok"
}

Warnings

{
  "data": "err",
  "value": "invalid_data"
}
{
  "data": "err",
  "value": "user_not_found"
}

Resource URI Method
USERS http://URI/api/user.php POST

header

{
  "content-type": "application/json"
}

payload

{
  "type": "users"
}

Success

{
  "0": {
    "user": "name"
  },
  "1": {
    "user": "name"
  },
  "data": "ok"
}

Warnings

{
  "data": "err",
  "value": "invalid_data"
}
{
  "data": "err",
  "value": "there_are_no_users_to_list"
}

Game

Resource URI Method
NEW http://URI/api/game.php POST

header

{
  "content-type": "application/json"
}

payload

{
  "type": "new",
  "user_id": "value"
}
Resource URI Method
SAVE http://URI/api/game.php POST
{
  "content-type": "application/json"
}

Payload

{
"type":"save",
"game_id":value,
"score":3000
}
Resource URI Method
RANKING GENERAL http://URI/api/game.php POST
{
  "content-type": "application/json"
}
{
"type":"ranking_general"
}
Resource URI Method
RANKING USER http://URI/api/game.php POST
{
  "content-type": "application/json"
}
{
"type":"ranking_player",
"user_id": user_id
}

Como citar este conteúdo

DE SOUZA, Edson Melo (2022, October 6). PHP API GAMES v.1.0.
Available in: https://github.com/EdsonMSouza/apigames

Ou BibTeX for LaTeX:

@misc{desouza2022apigame,
  author = {DE SOUZA, Edson Melo},
  title = {PHP API GAMES v.1.0},
  url = {https://github.com/EdsonMSouza/apigames},
  year = {2022},
  month = {October}
}

Licença

CC BY-SA 4.0

Este trabalho é licenciado sob a Creative Commons Attribution-ShareAlike 4.0 International License.

CC BY-SA 4.0

apigames's People

Contributors

edsonmsouza avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.