Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update PHP client library

Library update that handles signatures (even though USA TODAY does not
require them, just bringing library up to date)
  • Loading branch information...
commit 760ae225f1c058727172e5425a89d0e0dc3d66cc 1 parent b869f92
@mansilladev mansilladev authored
View
13 google-api-php-client/src/apiClient.php
@@ -148,14 +148,21 @@ public function setAuthClass($authClassName) {
}
/**
- * Set the developer key to use, these are obtained through the API Console.
- * @see http://code.google.com/apis/console-help/#generatingdevkeys
+ * Set the developer key to use
* @param string $developerKey
*/
public function setDeveloperKey($developerKey) {
self::$auth->setDeveloperKey($developerKey);
}
-
+
+ /**
+ * * Set the developer shared secret to use
+ * @param string $developersecret
+ */
+ public function setDeveloperSecret($developerSecret) {
+ self::$auth->setDeveloperSecret($developerSecret);
+ }
+
/**
* Set the application name, this is included in the User-Agent HTTP header.
* @param string $applicationName
View
18 google-api-php-client/src/auth/apiAuthNone.php
@@ -60,18 +60,30 @@ public function __construct() {
if (!empty($apiConfig['developer_key'])) {
$this->setDeveloperKey($apiConfig['developer_key']);
}
+ if (!empty($apiConfig['developer_secret'])) {
+ $this->setDeveloperSecret($apiConfig['developer_secret']);
+ }
}
public function setDeveloperKey($key) {$this->key = $key;}
public function sign(apiHttpRequest $request) {
global $apiConfig;
+ $sig = "";
if ($this->key) {
- $request->setUrl($request->getUrl() . ((strpos($request->getUrl(), '?') === false) ? '?' : '&')
- . $apiConfig['key_name'].'='.urlencode($this->key));
+ if ($this->secret) {
+ $sig = md5($this->key . $this->secret . (string)time());
+ }
+ $request->setUrl(
+ $request->getUrl() .
+ ((strpos($request->getUrl(), '?') === false) ? '?' : '&') .
+ $apiConfig['key_name'].'='.urlencode($this->key) .
+ (($sig) ? ('&' . $apiConfig['signature_name'] . '=' . urlencode($sig)) : '')
+ );
/*
* Mod above - static "key" parameter name changed
- * to global $apiConfig variable "key_name"
+ * to global $apiConfig variable "key_name" add signature
+ * if secret exists.
*/
}
return $request;
View
1  google-api-php-client/src/config.php
@@ -59,7 +59,6 @@
'developer_key' => '',
'key_name' => 'api_key',
'key_location' => 'query',
- 'foo' => 'bar',
// Which Authentication, Storage and HTTP IO classes to use.
'authClass' => 'apiAuthNone',
Please sign in to comment.
Something went wrong with that request. Please try again.