|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* SEOstats Example - Get Open-Site-Explorer (by MOZ) Metrics |
|
4
|
|
|
* |
|
5
|
|
|
* @package SEOstats |
|
6
|
|
|
* @author Stephan Schmitz <[email protected]> |
|
7
|
|
|
* @copyright Copyright (c) 2010 - present Stephan Schmitz |
|
8
|
|
|
* @license http://eyecatchup.mit-license.org/ MIT License |
|
9
|
|
|
* @updated 2013/12/17 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
// NOTE: The given path to the autoload.php assumes that you installed SEOstats via composer |
|
13
|
|
|
// and copied this example file from ./vendor/seostats/seostats/example/example.php to ./example.php |
|
14
|
|
|
// |
|
15
|
|
|
// If you did NOT installed SEOstats via composer but instead downloaded the zip file from github.com, |
|
16
|
|
|
// you need to follow this steps: |
|
17
|
|
|
// |
|
18
|
|
|
// 1. Comment-in line 24 (remove hash char "#") and comment-out line 25 (prepend hash char "#") |
|
19
|
|
|
// 2. Copy this example file (and the others) from ./example/example.php to ./example.php |
|
20
|
|
|
// |
|
21
|
|
|
// For further reference see: https://github.com/eyecatchup/SEOstats/issues/49 |
|
22
|
|
|
|
|
23
|
|
|
// Bootstrap the library / register autoloader |
|
24
|
|
|
#require_once realpath(__DIR__ . '/SEOstats/bootstrap.php'); |
|
25
|
|
|
require_once realpath(__DIR__ . '/vendor/autoload.php'); |
|
26
|
|
|
|
|
27
|
|
|
try { |
|
28
|
|
|
$url = 'http://www.nahklick.de/'; |
|
29
|
|
|
|
|
30
|
|
|
// Get Open-Site-Explorer metrics for the given URL. |
|
31
|
|
|
$ose = \SEOstats\Services\OpenSiteExplorer::getPageMetrics($url); |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
echo "Open-Site-Explorer metrics for " . $url . PHP_EOL; |
|
34
|
|
|
|
|
35
|
|
|
// MOZ Domain-Authority Rank - Predicts this domain's ranking potential in the search engines |
|
36
|
|
|
// based on an algorithmic combination of all link metrics. |
|
37
|
|
|
echo "Domain-Authority: " . |
|
38
|
|
|
$ose->domainAuthority->result . ' (' . // Int - e.g 42 |
|
39
|
|
|
$ose->domainAuthority->unit . ') - ' . // String - "/100" |
|
40
|
|
|
$ose->domainAuthority->descr . PHP_EOL; // String - Result value description |
|
41
|
|
|
|
|
42
|
|
|
// MOZ Page-Authority Rank - Predicts this page's ranking potential in the search engines |
|
43
|
|
|
// based on an algorithmic combination of all link metrics. |
|
44
|
|
|
echo "Page-Authority: " . |
|
45
|
|
|
$ose->pageAuthority->result . ' (' . // Int - e.g 48 |
|
46
|
|
|
$ose->pageAuthority->unit . ') - ' . // String - "/100" |
|
47
|
|
|
$ose->pageAuthority->descr . PHP_EOL; // String - Result value description |
|
48
|
|
|
|
|
49
|
|
|
// Just-Discovered Inbound Links - Number of links to this page found over the past %n days, |
|
50
|
|
|
// indexed within an hour of being shared on Twitter. |
|
51
|
|
|
echo "Just-Discovered Links: " . |
|
52
|
|
|
$ose->justDiscovered->result . ' (' . // Int - e.g 140 |
|
53
|
|
|
$ose->justDiscovered->unit . ') - ' . // String - e.g "32 days" |
|
54
|
|
|
$ose->justDiscovered->descr . PHP_EOL; // String - Result value description |
|
55
|
|
|
|
|
56
|
|
|
// Root-Domain Inbound Links - Number of unique root domains (e.g., *.example.com) |
|
57
|
|
|
// containing at least one linking page to this URL. |
|
58
|
|
|
echo "Linking Root Domains: " . |
|
59
|
|
|
$ose->linkingRootDomains->result . ' (' . // Int - e.g 210 |
|
60
|
|
|
$ose->linkingRootDomains->unit . ') - ' . // String - "Root Domains" |
|
61
|
|
|
$ose->linkingRootDomains->descr . PHP_EOL; // String - Result value description |
|
62
|
|
|
|
|
63
|
|
|
// Total Links - All links to this page including internal, external, followed, and nofollowed. |
|
64
|
|
|
echo "Total Links: " . |
|
65
|
|
|
$ose->totalLinks->result . ' (' . // Int - e.g 31571 |
|
66
|
|
|
$ose->totalLinks->unit . ') - ' . // String - "Total Links" |
|
67
|
|
|
$ose->totalLinks->descr . PHP_EOL; // String - Result value description |
|
68
|
|
|
} |
|
69
|
|
|
catch (\Exception $e) { |
|
70
|
|
|
echo 'Caught SEOstatsException: ' . $e->getMessage(); |
|
71
|
|
|
} |
|
72
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: