Skip to content

Commit

Permalink
Fix missing value errors to be more helpful
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Barber committed Apr 8, 2015
1 parent 8a316b7 commit 729447c
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
phpunit.xml
composer.lock
vendor
Expand Down
3 changes: 2 additions & 1 deletion examples/batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
$client->setApplicationName("Client_Library_Examples");
$apiKey = "<YOUR_API_KEY>"; // Change to your API key.
// Warn if the API key isn't changed!
if ($apiKey == '<YOUR_API_KEY>') {
if (strpos($apiKey, "<") !== false) {
echo missingApiKeyWarning();
exit;
} else {
$client->setDeveloperKey($apiKey);

Expand Down
6 changes: 2 additions & 4 deletions examples/fileupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,9 @@
fclose($handle);
}
echo pageHeader("File Upload - Uploading a large file");
if (
$client_id == '<YOUR_CLIENT_ID>'
|| $client_secret == '<YOUR_CLIENT_SECRET>'
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
if (strpos($client_id, "googleusercontent") == false) {
echo missingClientSecretsWarning();
exit;
}
?>
<div class="box">
Expand Down
6 changes: 2 additions & 4 deletions examples/idtoken.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ function. We store the resultant access token
}

echo pageHeader("User Query - Retrieving An Id Token");
if (
$client_id == '<YOUR_CLIENT_ID>'
|| $client_secret == '<YOUR_CLIENT_SECRET>'
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
if (strpos($client_id, "googleusercontent") == false) {
echo missingClientSecretsWarning();
exit;
}
?>
<div class="box">
Expand Down
6 changes: 2 additions & 4 deletions examples/multi-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@
}

echo pageHeader("User Query - Multiple APIs");
if (
$client_id == '<YOUR_CLIENT_ID>'
|| $client_secret == '<YOUR_CLIENT_SECRET>'
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
if (strpos($client_id, "googleusercontent") == false) {
echo missingClientSecretsWarning();
exit;
}
?>
<div class="box">
Expand Down
3 changes: 2 additions & 1 deletion examples/service-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
$key_file_location = ''; //key.p12

echo pageHeader("Service Account Access");
if ($client_id == '<YOUR_CLIENT_ID>'
if (strpos($client_id, "googleusercontent") == false
|| !strlen($service_account_name)
|| !strlen($key_file_location)) {
echo missingServiceAccountDetailsWarning();
exit;
}

$client = new Google_Client();
Expand Down
3 changes: 2 additions & 1 deletion examples/simple-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
$client->setApplicationName("Client_Library_Examples");
$apiKey = "<YOUR_API_KEY>"; // Change this line.
// Warn if the API key isn't changed.
if ($apiKey == '<YOUR_API_KEY>') {
if (strpos($apiKey, "<") !== false) {
echo missingApiKeyWarning();
exit;
}
$client->setDeveloperKey($apiKey);

Expand Down
6 changes: 2 additions & 4 deletions examples/simplefileupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@
}

echo pageHeader("File Upload - Uploading a small file");
if (
$client_id == '<YOUR_CLIENT_ID>'
|| $client_secret == '<YOUR_CLIENT_SECRET>'
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
if (strpos($client_id, "googleusercontent") == false) {
echo missingClientSecretsWarning();
exit;
}
?>
<div class="box">
Expand Down
6 changes: 3 additions & 3 deletions examples/templates/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function missingApiKeyWarning()
</h3>";
} else {
$ret = "Warning: You need to set a Simple API Access key from the Google API console:";
$ret .= "\nhttp://developers.google.com/console";
$ret .= "\nhttp://developers.google.com/console\n";
}
return $ret;
}
Expand All @@ -68,7 +68,7 @@ function missingClientSecretsWarning()
</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";
$ret .= " Google API console:\nhttp://developers.google.com/console\n";
}
return $ret;
}
Expand All @@ -84,7 +84,7 @@ function missingServiceAccountDetailsWarning()
</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";
$ret .= " Google API console:\nhttp://developers.google.com/console\n";
}
return $ret;
}
6 changes: 2 additions & 4 deletions examples/user-example.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ function. We store the resultant access token
}

echo pageHeader("User Query - URL Shortener");
if (
$client_id == '<YOUR_CLIENT_ID>'
|| $client_secret == '<YOUR_CLIENT_SECRET>'
|| $redirect_uri == '<YOUR_REDIRECT_URI>') {
if (strpos($client_id, "googleusercontent") == false) {
echo missingClientSecretsWarning();
exit;
}
?>
<div class="box">
Expand Down

0 comments on commit 729447c

Please sign in to comment.