· 9 years ago · Oct 20, 2016, 06:50 PM
1// connect to the database
2include('connect-db.php');
3
4// get the records from the database
5if ($result = $mysqli->query("SELECT id, category, url, DATE_FORMAT(domain_expiry_date, '%d/%m/%Y') AS domain_expiry_date, site_login_url, site_username_login, site_password_login, no_of_posts, tf, ct, domain_name_owner, DATE_FORMAT(domain_owner_dob, '%d/%m/%Y') AS domain_owner_dob, domain_owner_address, domain_owner_email, domain_owner_phone, email_account, email_account_url, email_account_address, email_username, email_password, registrar, registrar_url, registrar_username, registrar_password, hosting_company, hosting_url, hosting_username, hosting_password, DATE_FORMAT(hosting_expiry_date, '%d/%m/%Y') AS hosting_expiry_date, hosting_cpanel_url, hosting_cpanel_username, hosting_cpanel_password, sites_linked_out_to, DATE_FORMAT(last_post_date, '%d/%m/%Y') AS last_post_date, indexed FROM websites ORDER BY $field $sort"))
6
7{
8// display records if there are records to display
9if ($result->num_rows > 0)
10{
11
12// you can obtain you access id and secret key here:
13
14http://www.seomoz.org/api/keys
15$accessID = "accessid"; // * Add unique Access ID
16$secretKey = "secretkey"; // * Add unique Secret Key
17
18// Set your expires for several minutes into the future.
19// Values excessively far in the future will not be honored by the Mozscape API.
20$expires = time() + 300;
21
22// A new linefeed is necessary between your AccessID and Expires.
23$stringToSign = $accessID."n".$expires;
24
25// Get the "raw" or binary output of the hmac hash.
26$binarySignature = hash_hmac('sha1', $stringToSign, $secretKey, true);
27
28// We need to base64-encode it and then url-encode that.
29$urlSafeSignature = urlencode(base64_encode($binarySignature));
30
31// This is the URL that we want link metrics for.
32$objectURL = $_POST['url'];
33
34// Add up all the bit flags you want returned.
35// Learn more here: http://apiwiki.seomoz.org/categories/api-reference
36$cols = "103079215140";
37
38// Now put your entire request together.
39// This example uses the Mozscape URL Metrics API.
40$requestUrl = "http://lsapi.seomoz.com/linkscape/url-metrics/".urlencode($objectURL)."?Cols=".$cols."&AccessID=".$accessID."&Expires=".$expires."&Signature=".$urlSafeSignature;
41
42// We can easily use Curl to send off our request.
43$options = array(
44 CURLOPT_RETURNTRANSFER => true
45 );
46
47$ch = curl_init($requestUrl);
48curl_setopt_array($ch, $options);
49$content = curl_exec($ch);
50curl_close($ch);
51
52// * Store URL metrics in array
53
54$json_a = json_decode($content);
55
56// * Assign URL metrics to separate variables
57
58$pageAuthority = round($json_a->upa,0); // * Use the round() function to return integer
59$domainAuthority = round($json_a->pda,0);
60$externalLinks = $json_a->ueid;
61$theUrl = $json_a->uu;
62
63echo "<td" . $domainAuthority . "</td>";