Drush integration for SEO Stats module to download SEO Stats library
[project/seostats.git] / seostats.module
1 <?php
2
3 /**
4 * @file
5 * Makes use of the SEO Stats PHP library.
6 */
7
8 /**
9 * Include the SEO Stats PHP library.
10 */
11 function seostats_include_library() {
12 static $included;
13 if (!isset($included) && $path = libraries_get_path('seostats')) {
14 include $path . '/SEOstats/src/class.seostats.php';
15 $included = TRUE;
16 }
17 }
18
19 /**
20 * Fetch Google's PageRank for a URL.
21 */
22 function seostats_google_pagerank($url) {
23 $result = NULL;
24 seostats_include_library();
25 try {
26 $seostats_url = new SEOstats($url);
27 $pagerank = $seostats_url->Google_Page_Rank();
28 // $seostats_url->print_array('Google','json');
29 $result = $pagerank;
30 }
31 catch (SEOstatsException $e) {
32 watchdog('seostats', $e->getMessage(), array(), WATCHDOG_ERROR);
33 $result = FALSE;
34 }
35 return $result;
36 }