blob: 34241e9e4c7afd217a1e4a15852e5759fd4796ca (
plain)
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
|
<?php
/* Ad hoc functions to make the examples marginally prettier.*/
function isWebRequest()
{
return isset($_SERVER['HTTP_USER_AGENT']);
}
function pageHeader($title)
{
$ret = "";
if (isWebRequest()) {
$ret .= "<!doctype html>
<html>
<head>
<title>" . $title . "</title>
<link href='styles/style.css' rel='stylesheet' type='text/css' />
</head>
<body>\n";
if ($_SERVER['PHP_SELF'] != "/index.php") {
$ret .= "<p><a href='index.php'>Back</a></p>";
}
$ret .= "<header><h1>" . $title . "</h1></header>";
}
return $ret;
}
function pageFooter($file = null)
{
$ret = "";
if (isWebRequest()) {
// Echo the code if in an example.
if ($file) {
$ret .= "<h3>Code:</h3>";
$ret .= "<pre class='code'>";
$ret .= htmlspecialchars(file_get_contents($file));
$ret .= "</pre>";
}
$ret .= "</html>";
}
return $ret;
}
function missingApiKeyWarning()
{
$ret = "";
if (isWebRequest()) {
$ret = "
<h3 class='warn'>
Warning: You need to set a Simple API Access key from the
<a href='http://developers.google.com/console'>Google API console</a>
</h3>";
} else {
$ret = "Warning: You need to set a Simple API Access key from the Google API console:";
$ret .= "\nhttp://developers.google.com/console\n";
}
return $ret;
}
function missingClientSecretsWarning()
{
$ret = "";
if (isWebRequest()) {
$ret = "
<h3 class='warn'>
Warning: You need to set Client ID, Client Secret and Redirect URI from the
<a href='http://developers.google.com/console'>Google API console</a>
</h3>";
} else {
$ret = "Warning: You need to set Client ID, Client Secret and Redirect URI from the";
$ret .= " Google API console:\nhttp://developers.google.com/console\n";
}
return $ret;
}
function missingServiceAccountDetailsWarning()
{
$ret = "";
if (isWebRequest()) {
$ret = "
<h3 class='warn'>
Warning: You need to set Client ID, Email address and the location of the Key from the
<a href='http://developers.google.com/console'>Google API console</a>
</h3>";
} else {
$ret = "Warning: You need to set Client ID, Email address and the location of the Key from the";
$ret .= " Google API console:\nhttp://developers.google.com/console\n";
}
return $ret;
}
|