Skip to content

Commit f9e79bd

Browse files
committed
Merge pull request googleapis#519 from ianbarber/master
Fix missing value errors to be more helpful in examples
2 parents 8a316b7 + 729447c commit f9e79bd

File tree

10 files changed

+20
-26
lines changed

10 files changed

+20
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.DS_Store
12
phpunit.xml
23
composer.lock
34
vendor

examples/batch.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
$client->setApplicationName("Client_Library_Examples");
3535
$apiKey = "<YOUR_API_KEY>"; // Change to your API key.
3636
// Warn if the API key isn't changed!
37-
if ($apiKey == '<YOUR_API_KEY>') {
37+
if (strpos($apiKey, "<") !== false) {
3838
echo missingApiKeyWarning();
39+
exit;
3940
} else {
4041
$client->setDeveloperKey($apiKey);
4142

examples/fileupload.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,9 @@
109109
fclose($handle);
110110
}
111111
echo pageHeader("File Upload - Uploading a large file");
112-
if (
113-
$client_id == '<YOUR_CLIENT_ID>'
114-
|| $client_secret == '<YOUR_CLIENT_SECRET>'
115-
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
112+
if (strpos($client_id, "googleusercontent") == false) {
116113
echo missingClientSecretsWarning();
114+
exit;
117115
}
118116
?>
119117
<div class="box">

examples/idtoken.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,9 @@ function. We store the resultant access token
7979
}
8080

8181
echo pageHeader("User Query - Retrieving An Id Token");
82-
if (
83-
$client_id == '<YOUR_CLIENT_ID>'
84-
|| $client_secret == '<YOUR_CLIENT_SECRET>'
85-
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
82+
if (strpos($client_id, "googleusercontent") == false) {
8683
echo missingClientSecretsWarning();
84+
exit;
8785
}
8886
?>
8987
<div class="box">

examples/multi-api.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@
8888
}
8989

9090
echo pageHeader("User Query - Multiple APIs");
91-
if (
92-
$client_id == '<YOUR_CLIENT_ID>'
93-
|| $client_secret == '<YOUR_CLIENT_SECRET>'
94-
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
91+
if (strpos($client_id, "googleusercontent") == false) {
9592
echo missingClientSecretsWarning();
93+
exit;
9694
}
9795
?>
9896
<div class="box">

examples/service-account.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@
4141
$key_file_location = ''; //key.p12
4242

4343
echo pageHeader("Service Account Access");
44-
if ($client_id == '<YOUR_CLIENT_ID>'
44+
if (strpos($client_id, "googleusercontent") == false
4545
|| !strlen($service_account_name)
4646
|| !strlen($key_file_location)) {
4747
echo missingServiceAccountDetailsWarning();
48+
exit;
4849
}
4950

5051
$client = new Google_Client();

examples/simple-query.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737
$client->setApplicationName("Client_Library_Examples");
3838
$apiKey = "<YOUR_API_KEY>"; // Change this line.
3939
// Warn if the API key isn't changed.
40-
if ($apiKey == '<YOUR_API_KEY>') {
40+
if (strpos($apiKey, "<") !== false) {
4141
echo missingApiKeyWarning();
42+
exit;
4243
}
4344
$client->setDeveloperKey($apiKey);
4445

examples/simplefileupload.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@
9696
}
9797

9898
echo pageHeader("File Upload - Uploading a small file");
99-
if (
100-
$client_id == '<YOUR_CLIENT_ID>'
101-
|| $client_secret == '<YOUR_CLIENT_SECRET>'
102-
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
99+
if (strpos($client_id, "googleusercontent") == false) {
103100
echo missingClientSecretsWarning();
101+
exit;
104102
}
105103
?>
106104
<div class="box">

examples/templates/base.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function missingApiKeyWarning()
5252
</h3>";
5353
} else {
5454
$ret = "Warning: You need to set a Simple API Access key from the Google API console:";
55-
$ret .= "\nhttp://developers.google.com/console";
55+
$ret .= "\nhttp://developers.google.com/console\n";
5656
}
5757
return $ret;
5858
}
@@ -68,7 +68,7 @@ function missingClientSecretsWarning()
6868
</h3>";
6969
} else {
7070
$ret = "Warning: You need to set Client ID, Client Secret and Redirect URI from the";
71-
$ret .= "Google API console:\nhttp://developers.google.com/console";
71+
$ret .= " Google API console:\nhttp://developers.google.com/console\n";
7272
}
7373
return $ret;
7474
}
@@ -84,7 +84,7 @@ function missingServiceAccountDetailsWarning()
8484
</h3>";
8585
} else {
8686
$ret = "Warning: You need to set Client ID, Email address and the location of the Key from the";
87-
$ret .= "Google API console:\nhttp://developers.google.com/console";
87+
$ret .= " Google API console:\nhttp://developers.google.com/console\n";
8888
}
8989
return $ret;
9090
}

examples/user-example.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,9 @@ function. We store the resultant access token
9898
}
9999

100100
echo pageHeader("User Query - URL Shortener");
101-
if (
102-
$client_id == '<YOUR_CLIENT_ID>'
103-
|| $client_secret == '<YOUR_CLIENT_SECRET>'
104-
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
101+
if (strpos($client_id, "googleusercontent") == false) {
105102
echo missingClientSecretsWarning();
103+
exit;
106104
}
107105
?>
108106
<div class="box">

0 commit comments

Comments
 (0)