-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
83 lines (57 loc) · 2.17 KB
/
README
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Overview
--------
T3Net provides code for interacting with a web site from a native program. It
relies on libcurl to do HTTP requests. T3Net can take specifically formatted
data and parse it into easily usable data sets.
The C Side
----------
To get a dataset you simply call t3net_get_data(my_url). You will get a pointer
to a T3NET_DATA structure in return. This data structure has arrays of entries
and fields which can be easily utilized in your programs.
If you are retrieving a list of high scores, for instance, you can do something
like this:
T3NET_DATA * score_list;
int i;
score_list = t3net_get_data(url_to_score_script);
if(score_list)
{
for(i = 0; i < score_list->entries; i++)
{
printf("%d. %s - %s\n", i + 1, score_list->entry[i]->field[0]->data, score_list->entry[i]->field[1]->data);
}
}
The PHP Side
------------
A template is provided to help you get started. T3Net expects your script to
output data in this format:
Example Header\r\n
\r\n
\tfield_name_1: data1\r\n
\tfield_name_2: data2\r\n
\r\n
\tfield_name_1: data3\r\n
\tfield_name_2: data4\r\n
The script is self-explanatory. You just need to put in the correct database
info and make the data in the arrays match what is in your database.
Let's say you have a database with this structure:
my_dabatase
-leaderboards
-game
-name
-score
The database in the script should be set up like this:
$db_database = "my_database";
$db_name = "leaderboards";
$db_fields = array('game', 'name', 'score');
The output section should be set up like this:
$output_fields = array('name', 'score');
The settings should be set up like this:
$order_field = "score";
When you access this script through T3Net with the URL like this:
score_list = t3net_get_data("http://www.site.com/my_script.php?game=my_game");
you will get a data set containing all of the scores in the database where the
game field is set to "my_game" in order form highest to lowest.
You can change how the data is generated by passing arguments in the URL:
score_list = t3net_get_data("http://www.site.com/my_script.php?game=my_game&ascend=true&limit=10");
This set of arguments will sort the scores from lowest to highest and only
output 10 entries.