summaryrefslogtreecommitdiffstats
path: root/seostats.module
blob: 7d7e78353bb965824ddfcff99901f062162eadca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

/**
 * @file
 * Makes use of the SEO Stats PHP library.
 */

/**
 * Include the SEO Stats PHP library.
 */
function seostats_include_library() {
  static $included;
  if (!isset($included) && $path = libraries_get_path('seostats')) {
    include $path . '/SEOstats/src/class.seostats.php';
    $included = TRUE;
  }
}

/**
 * Fetch Google's PageRank for a URL.
 */
function seostats_google_pagerank($url) {
  $result = NULL;
  seostats_include_library();
  try {
    $seostats_url = new SEOstats($url);
    $pagerank = $seostats_url->Google_Page_Rank();
// $seostats_url->print_array('Google','json');
    $result = $pagerank;
  }
  catch (SEOstatsException $e) {
    watchdog('seostats', $e->getMessage(), array(), WATCHDOG_ERROR);
    $result = FALSE;
  }
  return $result;
}