2017 © Pedro Peláez
 

library google-news-sitemap

Easy way to do sitemap for google news

image

dionisiy13/google-news-sitemap

Easy way to do sitemap for google news

  • Monday, January 29, 2018
  • by dionisiy13
  • Repository
  • 1 Watchers
  • 1 Stars
  • 645 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 37 % Grown

The README.md

Google News Sitemap

Packagist Software License Total Downloads, (*1)

Class for generating the sitemap for google news. More about google news sitemap here, (*2)

Example of the sitemap from google, (*3)

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
       xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
 <url>
   <loc>http://www.example.org/business/article55.html</loc>
   <news:news>
     <news:publication>
       <news:name>The Example Times</news:name>
       <news:language>en</news:language>
     </news:publication>
     <news:genres>PressRelease, Blog</news:genres>
     <news:publication_date>2008-12-23</news:publication_date>
     <news:title>Companies A, B in Merger Talks</news:title>
     <news:keywords>business, merger, acquisition, A, B</news:keywords>
     <news:stock_tickers>NASDAQ:A, NASDAQ:B</news:stock_tickers>
   </news:news>
   <image:image>
      <image:loc>https://example.com/image.jpg</image:loc>
    </image:image>
    <image:image>
      <image:loc>https://example.com/photo.jpg</image:loc>
    </image:image>
 </url>
</urlset>
   ```

## Install

Via Composer

``` bash
$ composer require dionisiy13/google-news-sitemap

Usage

php $sitemap = new \Dionisiy\SitemapGoogle\Sitemap($pathToFile); $siteName = "example.com"; foreach ($posts as $item) { $sitemap->setGenres("Blog"); $sitemap->setKeywords($item['tags']); $sitemap->setLanguage("en"); $sitemap->setLoc($item['url']); $sitemap->setName($siteName); $sitemap->setPublicationDate($item['publishAt']->getTimestamp()); $sitemap->setTitle($item['title']); $sitemap->setImages($item['images']); $sitemap->addItem(); } $sitemap->write();, (*4)

$posts - list of news, (*5)

$pathToFile - where the file should apear. For example getcwd() . '/public' . '/sitemap_google_news.xml', (*6)

$item['date'] - should be DateTime, (*7)

Tags and genres could be empty., (*8)

Credits

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

29/01 2018

dev-master

9999999-dev https://github.com/dionisiy13/google-news-sitemap

Easy way to do sitemap for google news

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

  • ext-xmlwriter *

by :Dan Kurasov

php sitemap google news

29/01 2018

v1.0.0

1.0.0.0 https://github.com/dionisiy13/google-news-sitemap

Easy way to do sitemap for google news

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

  • ext-xmlwriter *

by :Dan Kurasov

php sitemap google news