1
|
|
|
<?php |
2
|
|
|
namespace SEOstats\Services; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* SEOstats extension for SEOmoz' OpenSiteExplorer data. |
6
|
|
|
* |
7
|
|
|
* @package SEOstats |
8
|
|
|
* @author Stephan Schmitz <[email protected]> |
9
|
|
|
* @copyright Copyright (c) 2010 - present Stephan Schmitz |
10
|
|
|
* @license http://eyecatchup.mit-license.org/ MIT License |
11
|
|
|
* @updated 2013/12/08 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
use SEOstats\SEOstats as SEOstats; |
15
|
|
|
use SEOstats\Config as Config; |
16
|
|
|
|
17
|
|
|
class OpenSiteExplorer extends SEOstats |
18
|
|
|
{ |
19
|
2 |
|
public static function getPageMetrics($url = false) |
20
|
|
|
{ |
21
|
2 |
|
$url = parent::getUrl($url); |
|
|
|
|
22
|
2 |
|
$dataUrl = sprintf(Config\Services::OPENSITEEXPLORER_URL, 'links', '1', urlencode($url)); |
23
|
|
|
|
24
|
2 |
|
$html = static::_getPage($dataUrl); |
25
|
2 |
|
$doc = parent::_getDOMDocument($html); |
|
|
|
|
26
|
2 |
|
$xpath = parent::_getDOMXPath(@$doc); |
|
|
|
|
27
|
|
|
|
28
|
2 |
|
$tooltipNodes = @$xpath->query('//*[@class="tooltip"]'); |
29
|
2 |
|
$resultNodes = @$xpath->query('//*[@class="has-tooltip"]'); |
30
|
2 |
|
$resultNodes2 = @$xpath->query('//*[@class="has-tooltip"]/span[1]'); |
31
|
2 |
|
$unitNodes = @$xpath->query('//*[@class="has-tooltip"]/span[2]'); |
32
|
|
|
|
33
|
2 |
|
if (0 < $resultNodes->length) { |
34
|
|
|
return (object) array( |
35
|
|
|
'domainAuthority' => (object) array( |
36
|
1 |
|
'result' => intval($resultNodes2->item(0)->nodeValue), |
37
|
1 |
|
'unit' => trim(strip_tags($unitNodes->item(0)->nodeValue)), |
38
|
1 |
|
'descr' => trim(strip_tags($tooltipNodes->item(0)->nodeValue)), |
39
|
1 |
|
), |
40
|
|
|
'pageAuthority' => (object) array( |
41
|
1 |
|
'result' => intval($resultNodes2->item(1)->nodeValue), |
42
|
1 |
|
'unit' => trim(strip_tags($unitNodes->item(1)->nodeValue)), |
43
|
1 |
|
'descr' => trim(strip_tags($tooltipNodes->item(1)->nodeValue)), |
44
|
1 |
|
), |
45
|
|
|
'justDiscovered' => (object) array( |
46
|
1 |
|
'result' => intval(str_replace(',', '', strip_tags($resultNodes->item(2)->nodeValue))), |
47
|
1 |
|
'unit' => trim(strip_tags($resultNodes2->item(2)->nodeValue)), |
48
|
1 |
|
'descr' => trim(strip_tags($tooltipNodes->item(2)->nodeValue)), |
49
|
1 |
|
), |
50
|
|
|
'linkingRootDomains' => (object) array( |
51
|
1 |
|
'result' => intval(str_replace(',', '', $resultNodes->item(3)->nodeValue)), |
52
|
1 |
|
'unit' => trim(strip_tags($resultNodes2->item(3)->nodeValue)), |
53
|
1 |
|
'descr' => trim(strip_tags($tooltipNodes->item(3)->nodeValue)), |
54
|
1 |
|
), |
55
|
|
|
'totalLinks' => (object) array( |
56
|
1 |
|
'result' => intval(str_replace(',', '', $resultNodes->item(4)->nodeValue)), |
57
|
1 |
|
'unit' => trim(strip_tags($resultNodes2->item(4)->nodeValue)), |
58
|
1 |
|
'descr' => trim(strip_tags($tooltipNodes->item(4)->nodeValue)), |
59
|
1 |
|
), |
60
|
1 |
|
); |
61
|
|
|
} |
62
|
|
|
else { |
63
|
1 |
|
return parent::noDataDefaultValue(); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.