0

I have used oauth process to get the sitemap from google webmaster. and followed the steps to generate refresh token from developer key, but i am not getting the results.

Here is my code:-

    $client = new Google_Client();
    $client->setAuthConfig('client_secret.json');
    $client->setAccessType("offline");
    $client->setIncludeGrantedScopes(true);
    $client->setApprovalPrompt('auto');
    $client->addScope(Google_Service_Webmasters::WEBMASTERS);
    $client->setRedirectUri('REDIERCT_URL');
    $client->setDeveloperKey('MY-DEVELOPER-KEY');
    $client->refreshToken('MYREFRESH-TOKEN');
    $client->authenticate('MYREFRESH-TOKEN');
    $newtoken = $client->getAccessToken();  
    $client->setAccessToken($newtoken['access_token']);         
    $service = new Google_Service_Webmasters($client);
   // $search = new Google_Service_Webmasters_Resource_Sitemaps;
    $results = $service->sitemaps->get('MYWEBSITE-URL', 'MYSITEMMAP-URL' , $resource = array()); 
    // While printing $results i am getting blank array. Am i doing something wrong?

Please correct me i am missing anything. Thanks in advance.

John Conde
  • 217,595
  • 99
  • 455
  • 496

0 Answers0