简体   繁体   中英

Google Search console API mistery

i'm trying to solve a mistery :) I'm trying to add a property url to my Google search console using php script through command line. The site seems to be adding correctly, as IU can list it using the list method, but I'm unable to find on which account it's being added :(

Here's the code i'm using to add a site

    $client_email = '12345-blablablabla@developer.gserviceaccount.com';
    $private_key = file_get_contents('mykey.p12');
    $scopes = array('https://www.googleapis.com/auth/webmasters');

    $credentials = new Google_Auth_AssertionCredentials(

        $client_email,
        $scopes,
        $private_key
    );
    $client = new Google_Client();
    $client->setAssertionCredentials($credentials);
    if ($client->getAuth()->isAccessTokenExpired()) {
        $client->getAuth()->refreshTokenWithAssertion();
    }
    $webmastersService = new Google_Service_Webmasters($client);
    $webmastersService->sites->add($url);

And if i call the method $webmastersService->sites->listSites()

I'm being returned the property I added just before.

But on which google account is this added ? This is a mystery :)

Thanks for your help

谜底解决了,因为可以在站点验证时定义关联的Google帐户!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM