-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.php
61 lines (48 loc) · 1.75 KB
/
example.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
<?php
require_once("VoteSmart.php");
// Initialize the VoteSmart object
$obj = new VoteSmart(
'CandidateBio.getBio',
Array(
'candidateId' => 9026
));
// Get the SimpleXML object
$x = $obj->getXmlObj();
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- pwned -->
<html lang="en">
<body>';
// Check and make sure there is no error
if (isset($x->errorMessage)) { // If there is, let's handle it
echo '
<div>' . $x->errorMessage . '</div>';
} else { // If not, let's go ->
// some quick and dirty assembly
$candName = $x->candidate->firstName . ' ' . $x->candidate->middleName . ' ' . $x->candidate->lastName . ' ' . $x->candidate->suffix;
if (!empty($x->candidate->photo)) $photo = '<img src="' . $x->candidate->photo . '" />';
echo '
<div>
<a href="' . $x->generalInfo->linkBack . '">' . $x->generalInfo->title . '</a>
</div>
<br /><br />
<table>
<tr>
<td>Name</td><td>' . $candName . '</td>
</tr><tr>
<td>Birth</td><td>' . $x->candidate->birthDate . ' (' . $x->candidate->birthPlace . ')</td>
</tr><tr>
<td>Gender</td><td>' . $x->candidate->gender . '</td>
</tr><tr>
<td>Photo</td><td>' . $photo . '</td>
</tr><tr>
<td>Party</td><td>' . $x->office->parties . '</td>
</tr><tr>
<td>Office</td><td>' . $x->office->name . '</td>
</tr>
';
}
echo '
</body>
</html>';
?>