/
index.php
127 lines (109 loc) · 5.07 KB
/
index.php
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
ini_set('memory_limit', '1024M');
include_once('ffxiv-lodestone-api.php');
function SimpleXMLElement_append($key, $value) {
// check class
if ((get_class($key) == 'SimpleXMLElement') && (get_class($value) == 'SimpleXMLElement')) {
// check if the value is string value / data
if (trim((string) $value) == '') {
// add element and attributes
$element = $key->addChild($value->getName());
foreach ($value->attributes() as $attKey => $attValue) {
$element->addAttribute($attKey, $attValue);
}
// add children
foreach ($value->children() as $child) {
SimpleXMLElement_append($element, $child);
}
} else {
// set the value of this item
$element = $key->addChild($value->getName(), trim((string) $value));
}
} else {
// throw an error
throw new Exception('Wrong type of input parameters, expected SimpleXMLElement');
}
}
if(isset($_GET)&&isset($_GET['request'])) {
$ffxiv = ffxivLodestoneAPI::GetInstance();
switch($_GET['request']) {
case 'search':
if(!isset($_GET['characterName'])) {
die('please specify a character name.');
}
$result = $ffxiv->SearchCharacterList($_GET['characterName'], (isset($_GET['server'])?$_GET['server']:false), (isset($_GET['class'])?$_GET['class']:false));
switch((isset($_GET['responseType'])?$_GET['responseType']:'xml')) {
case 'json': echo json_encode($result); break;
case 'xml': default: $xmlResp = new SimpleXMLElement('<Response></Response>'); foreach($result as $res) SimpleXMLElement_append($xmlResp,$res); echo $xmlResp->asXML(); break;
}
break;
case 'characterData':
if(!isset($_GET['characterID'])) {
die('please specify a character id.');
}
$result = $ffxiv->GetCharacterData($_GET['characterID']);
switch((isset($_GET['responseType'])?$_GET['responseType']:'xml')) {
case 'json': echo json_encode($result); break;
case 'xml': default: $xmlResp = new SimpleXMLElement('<Response></Response>'); foreach($result as $res) SimpleXMLElement_append($xmlResp,$res); echo $xmlResp->asXML(); break;
}
break;
case 'characterBiography':
if(!isset($_GET['characterID'])) {
die('please specify a character id.');
}
$result = $ffxiv->GetCharacterBiography($_GET['characterID']);
switch((isset($_GET['responseType'])?$_GET['responseType']:'xml')) {
case 'json': echo json_encode($result); break;
case 'xml': default: $xmlResp = new SimpleXMLElement('<Response></Response>'); SimpleXMLElement_append($xmlResp,$result); echo $xmlResp->asXML(); break;
}
break;
case 'characterRecentBlogEntries':
if(!isset($_GET['characterID'])) {
die('please specify a character id.');
}
$result = $ffxiv->GetCharacterRecentBlogEntries($_GET['characterID']);
switch((isset($_GET['responseType'])?$_GET['responseType']:'xml')) {
case 'json': echo json_encode($result); break;
case 'xml': default: $xmlResp = new SimpleXMLElement('<Response></Response>'); foreach($result as $res) SimpleXMLElement_append($xmlResp,$res); echo $xmlResp->asXML(); break;
}
break;
case 'characterFollowingCount':
if(!isset($_GET['characterID'])) {
die('please specify a character id.');
}
$result = $ffxiv->GetCharacterFollowingCount($_GET['characterID']);
switch((isset($_GET['responseType'])?$_GET['responseType']:'xml')) {
case 'json': echo json_encode($result); break;
case 'xml': default: $xmlResp = new SimpleXMLElement('<Response></Response>'); SimpleXMLElement_append($xmlResp,$result); echo $xmlResp->asXML(); break;
}
break;
case 'characterFollowerCount':
if(!isset($_GET['characterID'])) {
die('please specify a character id.');
}
$result = $ffxiv->GetCharacterFollowerCount($_GET['characterID']);
switch((isset($_GET['responseType'])?$_GET['responseType']:'xml')) {
case 'json': echo json_encode($result); break;
case 'xml': default: $xmlResp = new SimpleXMLElement('<Response></Response>'); SimpleXMLElement_append($xmlResp,$result); echo $xmlResp->asXML(); break;
}
break;
case 'characterHistory':
if(!isset($_GET['characterID'])) {
die('please specify a character id.');
}
$result = $ffxiv->GetCharacterHistory($_GET['characterID']);
switch((isset($_GET['responseType'])?$_GET['responseType']:'xml')) {
case 'json': echo json_encode($result); break;
case 'xml': default: $xmlResp = new SimpleXMLElement('<Response></Response>'); foreach($result as $res) SimpleXMLElement_append($xmlResp,$res); echo $xmlResp->asXML(); break;
}
break;
default:
die('request type not found');
break;
}
}
//6924763 - me
//1637278 - Justin
?>