0
即使我在搜索控制檯中有多個網站,Search Console API也會返回空數組。即使在我的搜索控制檯中有多個網站,Search Console API也會返回空陣列,但即使我在搜索控制檯中有多個網站
我在我的搜索控制檯中有幾個網站。當我使用api Explorer時,它們會返回到數組中。一旦我使用PHP或Python客戶端庫,使用我的服務帳戶憑據獲得空的結果。這似乎是一個權限問題,但我使用的服務帳戶擁有分配給它的所有者角色權限,因此沒有任何意義。任何幫助,將不勝感激!
這是我的代碼:
$client = new Google_Client();
$credentials_file = 'path/to/file.json';
$client->setAuthConfig($credentials_file);
$client->setScopes(['https://www.googleapis.com/auth/webmasters']);
$service = new Google_Service_Webmasters($client);
var_dump($service->sites->listSites()->getSiteEntry());
我的結果是:數組(0){} 即使它出現在搜索控制檯幾個網站。