Tuesday, April 11, 2017

How to get site map details from Google Webmaster Tool service in php

I am authenticating the Google Client and using it for siteMap data from webmaster. Here is the code which I am using for getting siteMap Data :

$gClient = new \Google_Client();
        if ($request->session()->get('token')) {
            $gClient->setAccessToken($request->session()->get('token'));
        }
        $client = new Google_Service_Webmasters($gClient);
        $webmastersService = new Google_Service_Webmasters_Resource_Sitemaps($client,"webmasters", "sitemaps", "list" );
        $webmastersService->listSitemaps("http://www.workvend.com/",["http://www.workvend.com/sitemap_index.xml"]);

But I am getting this error.

Google_Exception in Resource.php line 92: Unknown function: webmasters->sitemaps->list()

Please help me out , what wrong code is there?

Can any one tell what should be the 4th parameter passed to Google_Service_Webmasters_Resource_Sitemaps constructor ?



via subhajit

Advertisement