Browse Source

googlLib stats

Mark Scherer 10 years ago
parent
commit
a9d68edb6b
1 changed files with 17 additions and 0 deletions
  1. 17 0
      Lib/GooglLib.php

+ 17 - 0
Lib/GooglLib.php

@@ -118,6 +118,23 @@ class GooglLib {
 	}
 
 	/**
+	 * Retrieve the statistics for this key.
+	 *
+	 * @param string $key
+	 * @return array
+	 */
+	public function getStatistics($key) {
+		$url = $this->API = '?shortUrl=http://goo.gl/' . $key . '&projection=FULL&key=' . $this->APIKey;
+		$ch = curl_init($url);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+		$result = curl_exec($ch);
+		curl_close($ch);
+		$array = json_decode($result, true);
+		return $array;
+	}
+
+	/**
 	 * Retrieve the url for the statistics page for this key
 	 *
 	 * @param string $key