【问题标题】:Getting blank response from Google Talent API从 Google Talent API 获得空白响应
【发布时间】:2019-02-13 12:18:34
【问题描述】:

我的目标是在我的自定义网站中加载 Google Jobs 搜索结果。 因此,我在 google 上创建了帐户并启用了Google Talent API。在谷歌云 API 帐户上启用计费后,他们允许我使用 API 密钥和服务帐户凭据向此 API 请求。

我目前正在使用 PHP 和 api-client-php 库。

为此,我已从 google Console Talent Platform 下载凭据 (client_secret.json) 的 .json 文件。

这是我的 PHP 示例代码。

require 'vendor/autoload.php';

// Instantiate the client
$client = new Google_Client();

$api_key = 'AdsadsIzaSyBYAMxEPPasdadadw5VHITCdREQW7WYeIGs8jRlUYqlzLM';
$client->setDeveloperKey($api_key);
$client->setAuthConfig(getcwd() . '/client_secret.json');
$client->setScopes(array(
'https://www.googleapis.com/auth/jobs',
'https://www.googleapis.com/auth/cloud-platform'
));
$jobs = new Google_Service_JobService($client);
$location='USA';

// Set the Metadata
$requestMetadata = new Google_Service_JobService_RequestMetadata();
$requestMetadata->setUserId('000aaaa');
$requestMetadata->setSessionId('000aaaa-1212-21212');
$requestMetadata->setDomain('www.google.com');
$jobQuery = new Google_Service_JobService_JobQuery();
$keyword='software OR java';
$jobQuery->setQuery($keyword);

// Search Job Request
$searchRequest = new Google_Service_JobService_SearchJobsRequest();
$searchRequest->setRequestMetadata($requestMetadata);
$searchRequest->setQuery($jobQuery);
$searchRequest->setMode('JOB_SEARCH');
$jobService = new Google_Service_JobService($client);

$response = $jobService->jobs->search($searchRequest);

echo "<pre>";
print_r($response);
print_r($response->matchingJobs);

在发送这个请求时,我们得到了 matchjobs 空白数组,但 $response 有一些对象数组。这就像不输出,而只是请求信息。

这是迄今为止我们使用人才搜索 API 得到的响应。

Google_Service_JobService_SearchJobsResponse Object
(
    [collection_key:protected] => matchingJobs
    [appliedCommuteFilterType:protected] => Google_Service_JobService_CommutePreference
    [appliedCommuteFilterDataType:protected] => 
    [appliedJobLocationFiltersType:protected] => Google_Service_JobService_JobLocation
    [appliedJobLocationFiltersDataType:protected] => array
    [estimatedTotalSize] => 
    [histogramResultsType:protected] => Google_Service_JobService_HistogramResults
    [histogramResultsDataType:protected] => 
    [jobView] => 
    [matchingJobsType:protected] => Google_Service_JobService_MatchingJob
    [matchingJobsDataType:protected] => array
    [metadataType:protected] => Google_Service_JobService_ResponseMetadata
    [metadataDataType:protected] => 
    [nextPageToken] => 
    [numJobsFromBroadenedQuery] => 0
    [spellResultType:protected] => Google_Service_JobService_SpellingCorrection
    [spellResultDataType:protected] => 
    [totalSize] => 
    [internal_gapi_mappings:protected] => Array
        (
        )

    [modelData:protected] => Array
        (
        )

    [processed:protected] => Array
        (
        )

    [metadata] => Google_Service_JobService_ResponseMetadata Object
        (
            [collection_key:protected] => experimentIdList
            [experimentIdList] => Array
                (
                    [0] => 11300310
                    [1] => 11300342
                )

            [mode] => JOB_SEARCH
            [requestId] => f5cacd36-db29-4d65-851f-34a97c98af79:APAb7IRQAVop4QZ6rC2OlKjcEARRJQHI8w==
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

        )

)
Array
(
)

我在这里感到困惑,Talent API 可以在我们的网站上搜索和加载谷歌工作我们需要创建公司和工作,他们只提供使用 AI 和 ML 的高级搜索过滤器?

如果他们在我们的网站上提供谷歌工作,那么我的代码有什么问题?

请给我建议。

【问题讨论】:

    标签: php google-api artificial-intelligence google-api-php-client


    【解决方案1】:

    Google 的 Talent API 仅适用于您提供的数据,所以是的,您应该创建公司和职位,然后将搜索应用到这些职位。

    checklist 他们发布的用于启动使用此 API 的应用程序的第二步是索引公司和工作,其中明确提到这些来自您自己的数据库:

    至少创建一个公司。我们建议为 您数据库中所有有空缺职位的公司。

    为您的公司创造工作机会。我们建议为 您数据库中的所有空缺职位。

    支持这一令人失望的现实的其他证据是 Ivan Davchev 在宣布此 API 的 Google 会议后发布的 article

    什么是 Google Jobs API?

    这是搜索您的工作的一站式解决方案。与大多数基于云的搜索 > 解决方案一样,您需要为其提供索引并使其可搜索的文档(作业)。

    [...]

    不是聚合器,也不是开箱即用地提供“世界上所有的工作”。 > 所以你不能用这个 API 在一个下午建立一个 Indeed 竞争对手。它只搜索 > 您提供的内容,这就是为什么招聘委员会和申请人跟踪 > 系统 (ATS) 使用它是有意义的 — 职位发布在这些系统上并由这些系统管理。

    【讨论】:

    • > 它不是一个聚合器,也不提供开箱即用的“世界上所有工作”。现在他们有了看起来像聚合器的 Google Jobs。
    猜你喜欢
    • 1970-01-01
    • 2021-09-09
    • 1970-01-01
    • 1970-01-01
    • 2018-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多