Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Php mysql APP interface mobile interface API M-API open source code

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Open source protocol: Apache License 2.0

Source code address: https://github.com/movie0312/M-API.git

M-API

An overview. 1

1. Interface document structure. 3

Second, interface environment setting. 3

1. Development environment. 3

two。 Production environment. 3

Third, basic configuration instructions. 4

Fourth, mysql configuration instructions. 5

Fifth, the external interface entrance configuration description. 7

Description of interface parameters. 7

7. Code code description. 12

Overview

In order to facilitate the development of front-end and mobile interface, the corresponding functions are integrated into a Web API that can quickly set up applications, so as to speed up the project development cycle. M-API selectively exposes the database to the caller through simple settings. Of course, for security reasons, it is recommended to set the appropriate operation permissions. This document is suitable for PHPer with a certain foundation.

M-API development environment is: php-7.0.4, mysql-5.7.11. Php5.6.0 is also supported, and other versions have not been tested.

M-API operating environment needs to enable mbstring; encryption operation. Openssl; database operation needs to be enabled. Pdo_mysql is required.

M-API supports BCC and signing. Currently, only RSA encryption is supported. In view of the characteristics of RSA, when there is a large amount of interactive information, it is recommended to encrypt only sensitive information, and other information is symmetrically encrypted, or change the transport protocol to HTTPS. If you must use RSA, you can segment the information.

M-API supports get and post.

The M-API database currently supports only mysql.

All M-API uses PDO preprocessing to operate the database.

M-API supports mysql fields such as char, varchar, tinyint, smallint, mediumint, int, bigint, decimal, text.

M-API supports multiple database connections simultaneously. Similarly, multiple sets of basic settings are supported at the same time.

M-API supports operation permission settings at the table level and column level.

M-API can specify associated fields to avoid injection.

M-API supports automatic verification of data validity. Regular validation can be specified manually.

Both the received and outgoing data of M-API are json.

M-API does not support transactions. Please deal with it in the business logic.

M-API does not support join queries. Please use the view query.

The right of final interpretation rests with the developer.

Unfinished matters, follow-up supplement.

The ability is average, but the level is limited. Take it easy on me.

/ class/basic.class.php- basic class basic configuration information

/ class/mysql.class.php- database class mysql

/ class/mysql.config.class.php-mysql configuration class

/ class/rsa.class.php- encryption class rsa

/ class/standard.class.php- standard class common functions

/ pem/- key

/ index.php- external interface entry

/ showstruct.php- quickly display database structure

The following files need to be configured

/ class/basic.class.php

/ class/mysql.config.class.php

/ index.php

two。 Production environment

The following files need to be deleted

/ readme.docx

/ showstruct.php

Public static $_ config = array (

'default'= > array (

'Parameter'= > 'value'

),

'Custom configuration name'= > array (

'Parameter'= > 'value'

)

);

Basic configuration

Parameters.

Description

Value

Display_errors

Enable debugging

True / false

Rsa

Enable rsa encryption

True / false

Cipher

Enable BCC

True / false

Private_key_path

Path to the private key file

'string' (this option is valid when ras is true. When cipher is false, you need to pass in the folder name to automatically add subfolders after the path)

Public_key_path

The path to the public key file

'string' (this option is valid when ras is true. When cipher is false, you need to pass in the folder name to automatically add subfolders after the path)

Private_key_name

Private key file name

'string' (this option is valid when ras is true)

Public_key_name

Public key file name

'string' (this option is valid when ras is true)

Get

Enable get

True / false (usually false; when rsa is true, false is required)

Parameters.

Description

Value

Db_type

Database type

Mysql

Db_host

Server address

'string'

Db_port

Port

'int'

Db_name

Database name

'string'

Db_user

User name

'string'

Db_pwd

Password

'string'

Configuration description

It can be generated quickly through / showstruct.php. However, it is still recommended to set the appropriate permissions after generation.

Public static $_ tables = array (

'0customers = > array (

'0' = > 'Table name 1'

'Parameter'= > 'value'

),

'1percent = > array (

'0' = > 'Table name 2'

'Parameter'= > 'value'

)

);

Public static $_ fields = array (

'0customers = > array (

'0' = >' field name 1'

'1' = > 'Field Type 1'

'Parameter'= > 'value'

),

'1percent = > array (

'0' = >' field name 2'

'1' = > 'Field Type 2'

'Parameter'= > 'value'

)

);

Table permission configuration

Parameters.

Description

Value

Add

Allow to increase

True / false defaults to true

Del

Allow deletion

True / false defaults to true

Edit

Allow modification

True / false defaults to true

Select

Allow query

True / false defaults to true

Field permission configuration

Isuid

Identity identification

Used internally by the interface when used for identity; only one field per table needs to be set; any external calls are prohibited; and the edit and select settings are invalid. Default is false

Edit

Allow modification

True / false defaults to true

Select

Allow query

True / false defaults to true

Pattern

Regular filtering

'The string' regular expression is empty by default

The user operation authority is judged according to $data ['b'] ['i'].

Judge the time limit of user operation according to $data ['b'] ['d'].

Do user identity judgment based on $data ['b'] ['t'] and assign a value of $_ uid.

Incoming parameter

Parameters.

Description

Value

Data

Input value

'string' (encrypted / unencrypted) json

Outgoing parameter

Parameters.

Description

Value

State

Execution status

0 not executed / 1 executed

Code

Return code

See "code Code description"

Info

Return information

'string' (encrypted / unencrypted) json

Data name / value list (take javascript as an example)

Name

Description

Value

Data [b]

Basic content

'array' (see below)

Data [b] [i]

Identity identification

'string' is required

Example:

Var temp = 'id'

Data [b] [d]

Time stamp

'int' is required

Example:

Var temp = 1461143961

Name

Description

Value

Data [b] [t]

Token

'string' (identity id + MD5 (login password) + timestamp)

Optional (without this key defaults to seeion authentication)

Example:

Var temp = 'id49ba59abbe56e0571461143961'

Data [c]

Execution content

'array' (see below)

Data [c] [] [a]

Operation type

'int' (0 add, 1 delete, 2 modify, 3 query) required

0 returns an increase in id;1, 2 returns the number of affected rows, 3 returns a specific array.

Example:

Var temp = 0

Data [c] [] [t]

Table of operation

'int' (generated in the background and allows corresponding operations) is required

Example:

Var temp = 1

Data [c] [] [V]

Field valu

'required when the array' operation type is 0, 2

Format: 'field code': 'field value'

The field code is generated by the background and the corresponding operation is allowed

Example:

Var temp = {

'1': 'abc'

'2': true

'3': 1

}

Data [c] [] [w]

Conditions

'array' operation type is 1, 2, 3 optional

Format:

1. Conditional relation

'logic':' specific relationship'

Conditional relationship between field and field

Or / and defaults to and

two。 Specific conditions

I. 'logic':' specific relationship'

Conditional relationships within a field

Or / and defaults to and

ii. 'Field code': {

'condition type': 'condition value' * condition value may be 'array''

}

The field code is generated by the background and the corresponding operation is allowed

3. Condition type

Equal to: 'eq':' specific value'

Not equal to: 'neq':' specific value'

Greater than: 'gt':' specific value'

Greater than or equal to: 'egt':' specific value'

Less than: 'lt':' specific value'

Less than or equal to: 'elt':' specific value'

Fuzzy query:

'like':' specific value'

'like': 'arrayA'

ArrayA:

'0':' arrayB'

'1': 'conditional relation (or / and)'

ArrayB:

'Index': 'specific value'

Fuzzy query (inverse): 'notlike':' specific value'

Interval query:

'between': 'array'

Array:

'0': 'starting value'

'1': 'end value'

Interval query (inverse): 'notbetween':' array' (ibid.)

IN query:

'in': 'array'

Array:

'Index': 'specific value'

IN query (inverse): 'notin':' array' (ibid.)

Example:

Var temp = {

'logic': 'or'

'1': {

'logic': 'and'

'eq':' 1'

'like': {

'0': {

'0':' test%'

'1': 'try%'

}

'1': 'or'

}

}

'2': {

'eq':'2'

}

}

Data [c] [] [s]

Show field

'required for string' operation type 3

Format: 'field code 1, field code 2, field code 3, …'

The field code is generated by the background and the corresponding operation is allowed

Example:

Var temp = ['1percent,' 2percent, '3percent,' 5']

Data [c] [] [o]

Sort

'array' operation type 3 is optional

Format: 'field code': 'sort by'

Sort by:'/ desc is empty by default (ascending order)

The field code is generated by the background and the corresponding operation is allowed

Example:

Var temp = {

'1':''

'2': 'desc'

}

Data [c] [] [l]

Start and quantity

'string' operation type 3 is optional

Format: 'start, quantity'

Example:

Var temp = ['1percent,' 5']

Code description

Code

Description

0000

Normal

A001

Php requires mbstring extension support

A002

Deny access to the wrong identity

C000

Configuration file debug mode error

C001

Configuration file get data mode error

C002

The path of the configuration file private key file is wrong.

C003

Configuration file public key file path error

C004

Configuration file private key file name error

C005

Configuration file public key file name error

C006

Configuration file BCC error

C007

Configuration file encryption switch error

Code

Description

C008

Configuration file database parameter error

C009

Configuration file database type error

C010

The mysql basic settings table allows you to add switch setting errors

C011

Mysql basic settings table allows delete switch setting error

C012

Mysql basic settings table allows you to modify switch setting errors

C013

Mysql basic Settings table allows query switch settings to be incorrect

C014

The mysql basic Settings field allows you to modify switch setting errors

C015

The mysql basic Settings field allows the query switch to set errors

C016

Mysql basic Settings field identity switch setting error

D001

Php requires pdo_mysql extension support

D002

Database connection error

D003

Sql execution error

E001

Php requires openssl extension support

E002

Private key file does not exist

E003

The private key is not available

E004

Public key file does not exist

E005

The public key is not available

E006

Encryption error

E007

Decryption error

E008

Error in private key path

E009

Public key path error

Code

Description

G001

Missing incoming parameter data [b]

G002

Missing incoming parameter data[ b] [I]

G003

Input value error data [b] [I]

G004

Missing incoming parameter data[ b] [d]

G005

Input value error data [b] [d]

G006

Missing incoming parameter data[ c]

G007

Missing incoming parameter data[ c] [] [a]

G008

Input value error data [c] [] [a]

G009

Missing incoming parameter data[ c] [] [t]

G010

Input value error data [c] [] [t]

G011

Incoming parameters are not allowed to increase the operation data [c] [] [t]

G012

Incoming parameters do not allow delete operation data [c] [] [t]

G013

Incoming parameters are not allowed to modify the operation data [c] [] [t]

G014

Incoming parameters do not allow query operation data [c] [] [t]

G015

Missing incoming parameter data[ c] [] [v]

G016

Incoming parameters are not allowed to change the operation data [c] [] [v] []

G017

Input parameter error data [c] [] [v] []

G018

Incoming values are not allowed to be empty data [c] [] [v] []

G019

Input value type error data [c] [] [v] []

G020

Input value is out of range data [c] [] [v] []

G021

Input value format error data [c] [] [v] []

Code

Description

G022

Incoming parameters do not allow any operation data [c] [] [v] []

G023

Incoming parameters do not allow any operation data [c] [] [w] []

G024

Input parameter error data [c] [] [w] []

G025

Input parameter error data [c] [] [w] [] []

G026

Missing incoming parameter data[ c] [] [s]

G027

Input value error data [c] [] [s]

G028

Incoming value does not allow any operation data [c] [] [s]

G029

Incoming values do not allow query operation data [c] [] [s]

G030

Input parameter error data [c] [] [o] []

G031

Incoming parameters do not allow any operation data [c] [] [o] []

G032

Input value error data [c] [] [o] []

G033

This value allows you to enter only two parameters data [c] [] [l]

G034

Input value error data [c] [] [l] []

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

  • SpringBoot (12): integrated Druid

    First, add dependencies

    © 2024 shulou.com SLNews company. All rights reserved.

    12
    Report