noud/laravel-seo-google-indexing-api

Laravel SEO Google 搜索索引 API

v1.0.3 2019-12-28 16:49 UTC

This package is auto-updated.

Last update: 2024-09-12 00:34:32 UTC


README

通知 Google 搜索 索引 API 您的 职位发布 URL。

要求

  • PHP 7.2+
  • Laravel 5.6+

安装

在您的终端/cmd 中运行此命令来安装包

composer require noud/laravel-seo-google-indexing-api

配置

将这些设置添加到您的 .env 文件中。

GOOGLE_SERVICE_ENABLED=true
GOOGLE_SERVICE_ACCOUNT_JSON_LOCATION="/var/www/seo/config/google/google-service-account.json"

用法

以下是一个用法示例

<?php

namespace App\Http\Controllers;

use App\Models\JobPosting;
use GoogleIndexing\Services\IndexingService;

class GoogleIndexingController extends Controller
{
    private $indexingService;

    public function __construct(IndexingService $indexingService)
    {
        $this->indexingService = $indexingService;
    }

    public function updateURL(JobPosting $jobPosting)
    {
        $this->indexingService->update($jobPosting->url);
    }

    public function removeURL(JobPosting $jobPosting)
    {
        $this->indexingService->remove($jobPosting->url);
    }

    public function statusURL(JobPosting $jobPosting)
    {
        $this->indexingService->status($jobPosting->url);
    }
}