-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple-get.pwn
More file actions
30 lines (26 loc) · 858 Bytes
/
simple-get.pwn
File metadata and controls
30 lines (26 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// simple-get.pwn — fire a GET request and print the response.
//
// Demonstrates:
// * The minimal request shape.
// * The four-argument callback signature.
// * Inspecting the error code before reading the body.
#include <a_samp>
#include <https_samp>
public OnGameModeInit()
{
// The "1" here is an arbitrary correlation id; the plugin echoes it back.
https(1, HTTPS_GET, "https://httpbin.org/get", "", "OnSimpleGet");
return 1;
}
forward OnSimpleGet(index, response[], status, error);
public OnSimpleGet(index, response[], status, error)
{
if (error != HTTPS_ERROR_NONE)
{
printf("[example] request %d failed: error=%d", index, error);
return 1;
}
printf("[example] request %d ok: status=%d, %d bytes", index, status, strlen(response));
printf("[example] body: %s", response);
return 1;
}