Giter Site home page Giter Site logo

api-rest-php's Introduction

API-REST com PHP

  • Essa API foi desenvolvida no padrão REST usando PHP, não possui as melhores práticas ou padrões de projeto poís está foi apenas uma tentativa do desenvolvimento de uma API-REST com PHP. qualquer crítica, fork ou contribuição é bem vinda !!

ROTAS

CREATE MUSIC

MÉTODO : POST URI : /backend/?/create_song

EXEMPLO DE USO

		import axios from "axios";

		const options = {
		  method: 'POST',
		  url: 'http://127.0.0.1/iuri/API_MUSICAS/backend/',
		  params: {'/create_song': ''},
		  headers: {'Content-Type': 'application/json'},
		  data: {
		    name: 'alguma coisa',
		    singer: 'cobalto',
		    time: '1-00s',
		    description: 'ddjd dddmd ddjjd'
		  }
		};

		axios.request(options).then(function (response) {
		  console.log(response.data);
		}).catch(function (error) {
		  console.error(error);
		});

RESPONSE

  • SUCESSO => 201
  • ERRO => 501

TAKE ALL MUSICS

MÉTODO : GET URI : /backend/?/take_songs

EXEMPLO

		import axios from "axios";

		const options = {
		  method: 'GET',
		  url: 'http://127.0.0.1/iuri/API_MUSICAS/backend/',
		  params: {'/take_songs': ''}
		};

		axios.request(options).then(function (response) {
		  console.log(response.data);
		}).catch(function (error) {
		  console.error(error);
		});

RESPONSE

  • STATUS 200
		[
		  {
		    "id": "1",
		    "name": "alalal",
		    "time": "10s",
		    "description": "ddjd dddmd ddjjd",
		    "singer": "claudio"
		  },
		  {
		    "id": "2",
		    "name": "alalal",
		    "time": "10s",
		    "description": "ddjd dddmd ddjjd",
		    "singer": "claudio"
		  }
		]
  • STATUS 401

    • não existem musicas

TAKE ONE MUSIC

MÉTODO : GET URI : /backend/?idToSearch=9999

EXEMPLO

		import axios from "axios";

		const options = {
		  method: 'GET',
		  url: 'http://127.0.0.1/iuri/API_MUSICAS/backend/',
		  params: {idToSearch: '4'}
		};

		axios.request(options).then(function (response) {
		  console.log(response.data);
		}).catch(function (error) {
		  console.error(error);
		});

RESPONSE

  • STATUS 404
    • POSTAGEM NÃO ENCONTRADA
  • STATUS 200
			{
			  "id": "4",
			  "nome": "alguma coisa",
			  "duration": "1-00s",
			  "singer": "cobalto",
			  "description": "ddjd dddmd ddjjd"
			}

DELETE MUSIC

MÉTODO : DELETE URI : /backend/?idToDelete=9999

		import axios from "axios";

		const options = {
		  method: 'DELETE',
		  url: 'http://127.0.0.1/iuri/API_MUSICAS/backend/',
		  params: {idToDelete: '5'}
		};

		axios.request(options).then(function (response) {
		  console.log(response.data);
		}).catch(function (error) {
		  console.error(error);
		});

RESPONSE

  • STATUS 301
    • deletado com sucesso
  • STATUS 404
    • não encontrada a musica

api-rest-php's People

Contributors

iurisampaio avatar

Stargazers

 avatar

Watchers

 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.