PHP Classes
elePHPant
Icontem

File: access_top_pages.php

Recommend this page to a friend!
  Classes of Manuel Lemos  >  PHP Webmaster Tools API  >  access_top_pages.php  >  Download  
File: access_top_pages.php
Role: Example script
Content type: text/plain
Description: Example script to retrieve the top site pages with more search visits
Class: PHP Webmaster Tools API
Access Google Webmaster Tools API for given sites
Author: By
Last change: Fixed the google client id and secret variables.
Date: 8 months ago
Size: 1,840 bytes
 

Contents

Class file image Download
<?php
/*
 * access_top_pages.php
 *
 * @(#) $Id: access_top_pages.php,v 1.6 2015/10/18 03:28:44 mlemos Exp $
 *
 */

    /*
     * Get the http.php file from http://www.phpclasses.org/httpclient
     */
   
require('http.php');

   
/*
     * Get the oauth_client.php and file_oauth_client.php files
     * from http://www.phpclasses.org/oauth-api
     */
   
require('oauth_client.php');
    require(
'file_oauth_client.php');
   
   
/*
     * Get the forms.php and form_layout_vertical.php files
     * from http://www.phpclasses.org/formsgeneration
     */
   
require('forms.php');
    require(
'form_layout_vertical.php');
   
    require(
'top_pages.php');
    require(
'web_master_tools.php');

   
$top_pages = new top_pages_class;
   
$top_pages->current_url = 'http://'.$_SERVER['HTTP_HOST'].
       
dirname(strtok($_SERVER['REQUEST_URI'],'?')).'/access_top_pages.php';

   
$top_pages->google_client_id = ''; $application_line = __LINE__;
   
$top_pages->google_client_secret = '';
   
    if(
strlen($top_pages->google_client_id) == 0
   
|| strlen($top_pages->google_client_secret) == 0)
        die(
'Please go to Google APIs console page '.
           
'http://code.google.com/apis/console in the API access tab, '.
           
'create a new client ID, and in the line '.$application_line.
           
' set the client_id to Client ID and client_secret with Client Secret. '.
           
'The callback URL must be '.$top_pages->current_url.' but make sure '.
           
'the domain is valid and can be resolved by a public DNS.');

    if((
$success = $top_pages->Initialize()))
       
$success = $top_pages->Finalize($top_pages->Process());
    if(
$top_pages->exit)
        exit;
    if(
$success)
       
$top_pages->Output();
    else
    {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Top pages error</title>
</head>
<body>
<h1>Top pages error</h1>
<pre>Error: <?php echo HtmlSpecialChars($top_pages->error); ?></pre>
</body>
</html>
<?php
   
}
?>