Giter Club home page Giter Club logo

simple_chat_php's Introduction

Simple Chat Backend PHP

CI Status

BCH compliance


Written using PHP 7 and SQLite3.

How to run: copy all files into a webserver - tested using Apache

How to run tests: 'phpunit tests'

How to test: 'curl -X GET http://localhost:8080/api/getMessages?username=maxmouse'

  • URL

<_/api/getUserByUserName>

  • Method:

    <Get User by User Name>

    GET

  • Data Params

    Required:

    username=[username]

  • Success Response:

    • Code: 200
      Content: {"id":42,"username":"maxmouse"}
  • Error Response:

    <If the user does NOT exist.>

    • Code: 404 Not Found
      Content: ``

    • Error Response:

    <Username field is missing or invalid.>

    • Code: 400 Bad Request
      Content: ``
  • URL

    </api/addUser>

  • Method:

    <Add user>

    POST

  • Data Params

    Required:

    username=[username]

  • Success Response:

    • Code: 201
      Content: ``
  • Error Response:

    <If the user data is invalid or username is already taken.>

    • Code: 400 Bad Request
      Content: ``
  • URL

    </api/getMessages>

  • Method:

    GET

  • Data Params

    Required:

    username=[username]

  • Success Response:

    • Code: 200
      Content: [{"id":"5","user_id":"43","from_user":"42","message":"oioioio","time":"2018-12-03 00:43:59"},{"id":"4","user_id":"43","from_user":"42","message":"saiuho328","time":"2018-12-03 00:43:46"}]
  • Error Response:

    <If the user data is invalid or username is already taken.>

    • Code: 400 Bad Request
      Content: ``
  • URL

    </api/sendMessage>

  • Method:

    <Send message to an user>

    POST

  • Data Params

    Required:

    to=[username] from=[username] text=[message text]

  • Success Response:

    • Code: 200
      Content: ``
  • Error Response:

    <If the sender or recepient user does NOT exists in the database or any field is missing.>

    • Code: 400 Bad Request
      Content: ``
  • Notes:

<Things to improve: unit tests, add functional tests, error handling.>

simple_chat_php's People

Contributors

maxmousee 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.