07.02.2012, 07:38
Introduction
In this tutorial, I will teach you about HTTP on SA-MP.
What is HTTP?
HTTP is an application protocol for hypermedia information systems. It stands for Hypertext Transfer Protocol.
Why it's needed?
It's needed to permit intermediate network elements to improve or enable communications between clients and servers. With it, you can create the following things:
How to use it?
It's not really hard to use, but to get started using it, you need to know few things first.
Let me now explain in details in every parameters(arguments). The index is used to differentiate the requests that are sent to the same callback which you can use for player. The type as mentioned before is the request type you want to send. The URL is the url you want to request to get data. The data is used for POST to send request with. And last but not least, the callback which is used to get responses to the request. The response code 200 means that the request succeed. There is also and example script on SA-MP WIKI on HTTP. If you have any question please let me know by posting below.
Note: This thread will be updated frequently depending on the criticism and questions.
In this tutorial, I will teach you about HTTP on SA-MP.
What is HTTP?
HTTP is an application protocol for hypermedia information systems. It stands for Hypertext Transfer Protocol.
Why it's needed?
It's needed to permit intermediate network elements to improve or enable communications between clients and servers. With it, you can create the following things:
- Radio Station
- E-Mail Sender
How to use it?
It's not really hard to use, but to get started using it, you need to know few things first.
pawn Code:
http
(
index, // ID used to differentiate requests that are sent to the same callback.
type, // The request type.
url[], // The request URL. (Without 'http://')
data[], // Any POST data you want to send with the request.
callback[] // Name of the callback function you want to use to handle responses to this request.
// Returns 1(true) on Success and 0(false) on Failure
)
Request Type | Method |
HEAD | Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content. |
GET | Requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect. |
POST | Submits data to be processed to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both. |
Response Codes | ID |
HTTP_ERROR_BAD_HOST | 1 |
HTTP_ERROR_NO_SOCKET | 2 |
HTTP_ERROR_CANT_CONNECT | 3 |
HTTP_ERROR_CANT_WRITE | 4 |
HTTP_ERROR_CONTENT_TOO_BIG | 5 |
HTTP_ERROR_MALFORMED_RESPONSE | 6 |
Let me now explain in details in every parameters(arguments). The index is used to differentiate the requests that are sent to the same callback which you can use for player. The type as mentioned before is the request type you want to send. The URL is the url you want to request to get data. The data is used for POST to send request with. And last but not least, the callback which is used to get responses to the request. The response code 200 means that the request succeed. There is also and example script on SA-MP WIKI on HTTP. If you have any question please let me know by posting below.
Note: This thread will be updated frequently depending on the criticism and questions.