PHP code for POST JSON String Basic Authentication Example
This PHP code snippet was generated automatically for the POST JSON String Basic Authentication example.<< Back to the POST JSON String Basic Authentication example
What is HTTP?
Hypertext Transfer Protocol is a data transfer protocol that is widely used to transfer data between HTTP clients (browsers and mobile apps) and servers. HTTP is based on "client-server" technology. The client makes a request and initiates a connection, and the server receives the request and then executes it and sends the result to the client. HTTP defines various request methods that indicate the desired action (add, update, delete) for a given resource. Each request method implements its semantics and performs a specific action.
What is HTTP Authentication?
HTTP Authentication is a simple request and response method by which a server can request authentication information from a client and provide a framework for controlling access to resources. Authentication is a consequence of determining whether a client has the right to access a resource. HTTP supports authentication as a means of negotiating access to a protected resource.
What is Basic Authentication?
Basic Authentication is a simple authentication method built into the HTTP protocol. The Basic Authentication sends the base64 encoded string with the username and password in the Authorization header. Basic Authentication should only use in conjunction with other security mechanisms such as HTTPS/SSL for security reasons. To send basic authentication credentials to the server, you need to convert the "username: password" pair to a Base64 encoded string and pass it in the authorization request header.
Basic Authentication Syntax
The following is the common syntax for Basic Authentication header:
Where:
- Authorization: standard HTTP authorization header
- Basic: indicates HTTP Authorization type
What is JSON?
JSON (JavaScript Object Notation) is a text-based format for structured storage and data exchange in a human-readable format. JSON is used in almost all scripting languages. JSON comes from JavaScript and has a syntax similar to JavaScript but can be used separately from it. JSON allows information to be transmitted over the network. After receiving data in JSON format, the client converts the data into objects in the given programming language. For example, for JavaScript, the conversion is done by calling the JSON.parse(data) method. JSON itself has no methods, only properties. Conversions from JSON data to objects are done by calling methods of the programming language; JSON is not the only data storage format. There are other formats for the same purpose, such as XML and YAML.
What is POST request?
HTTP POST is one of the most commonly used HTTP methods. The POST request may or may not contain data. The POST requests are usually used when submitting web forms or when uploading files to a server. The POST data is included in the body of the POST message. The Content-Type header indicates the type of the POST request body, and the length is specified in the Content-Length header.