浏览代码

googlLib stats

Mark Scherer 10 年之前
父节点
当前提交
a9d68edb6b
共有 1 个文件被更改,包括 17 次插入0 次删除
  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