I just set up my Google for Jobs including Indexing API(Using PHP), Service Account and Search Console. But I don't see any recruit results in Google for Jobs even I got status message "OK" and "200"
- Created my new Google account for Jobs
2. Created a service account with Google API as an owner(With JSON) Created a new OAuth authorization information at the same time.
3.
Verified my site ownership with Google Search Console.
Added my service account's e-mail address.
(just like this one:
XXX@XXXiam.googleserviceaccount.com)
4.
Download the PHP library from
https://github.com/googleapis/google-api-php-client/releases
Copy this file "Google-api-php-client" folder into the same directory as recruit HTML.
(Example)
Document/recruit.html
Document/google-api-php-client
Download the Indexing files from https://github.com/googleapis/google-api-php-client-services
Copy these two files which have been downloaded from "Indexing files"
src/Google/Service/Indexing
src/Google/Service/Indexing.php
and paste them into the google-api-php-client folder
(Example)
Document/google-api-php-client
Document/google-api-php-client/Indexing.php
Document/google-api-php-client/Indedxing
- Create the PHP file to for Indexing API(Code below)
6. Upload all of these files into the server and access the PHP directory with a web browser.
And I got "OK" and "200" starting with GuzzleHttp\Psr7\Response Object ...(I don't know how this is called)
- About a whole 2 days passed after the access to the PHP directory with a browser. But I still don't see any results on Google for Jobs.
<?php
require_once 'google-api-php-client/vendor/autoload.php';
$client = new Google_Client();
// service_account_file.json is the private key that you created for your service account.
$client->setAuthConfig('X.json');
$client->addScope('https://www.googleapis.com/auth/indexing');
// Get a Guzzle HTTP Client
$httpClient = $client->authorize();
$endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish';
// Define contents here. The structure of the content is described in the next step.
$content = "{
\"url\": \"https://X.html\",
\"type\": \"URL_UPDATED\"
}";
$response = $httpClient->post($endpoint, [ 'body' => $content ]);
$status_code = $response->getStatusCode();
print_r($response);
echo "\n";
echo "$status_code";
I didn't see any error message but
- I'm not sure I did the correct thing.
(Accessing the PHP on the server with browser and confirm the status code 200 and OK is fine?)