├── LICENSE ├── README.md ├── composer.json ├── pinger.jpg └── src ├── LaravelPingerServiceProvider.php ├── Pinger.php ├── PingerFacade.php ├── config └── config.php └── views └── xml.blade.php /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Dinar Garipov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Laravel Weblogs Pinger 2 | 3 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) 4 | [![Laravel Version](https://img.shields.io/badge/laravel-5-orange.svg?style=flat-square)](http://laravel.com) 5 | 6 | Weblog system blogs pinger for Laravel 5. 7 | 8 | Easy way to notify search engines about your new or updated posts in blog. 9 | 10 | ## Install 11 | 12 | Add 13 | 14 | ``` JSON 15 | "garf/laravel-pinger": "2.*" 16 | ``` 17 | 18 | to your `composer.json` file into `require` section. 19 | 20 | Then type in console 21 | 22 | ``` BASH 23 | $ composer update 24 | ``` 25 | 26 | When update completed, add to your `config/app.conf` file to `providers` section 27 | 28 | ``` PHP 29 | 'providers' => [ 30 | // ... 31 | Garf\LaravelPinger\LaravelPingerServiceProvider::class, 32 | ] 33 | ``` 34 | 35 | If you want to use `Pinger` facade, add to same file at the `aliases` section 36 | 37 | ``` PHP 38 | 'aliases' => [ 39 | // ... 40 | 'Pinger' => Garf\LaravelPinger\PingerFacade::class, 41 | ] 42 | ``` 43 | 44 | ## Publish with artsian 45 | 46 | ``` PHP 47 | php artisan vendor:publish 48 | ``` 49 | Publishes a pinger.php file to config directory. Add and remove all your ping sites in this file. 50 | Be sure to review the ping responses from the ping sites you add because there are many ping sites 51 | and do not all provide a uniform response. Some may require additional parameters. Some may stop working. 52 | 53 | ## Usage 54 | 55 | ### Send ping to services 56 | 57 | #### Sending to all services at once 58 | 59 | ``` php 60 | Pinger::pingAll('Title of post', 'http://url.of/your-post', 'http://url.of/your-rss(optional)'); 61 | ``` 62 | 63 | #### Send pings to separate services 64 | 65 | **Google** 66 | 67 | ``` php 68 | Pinger::pingGoogle('Title of post', 'http://url.of/your-post', 'http://url.of/your-rss(optional)'); 69 | ``` 70 | 71 | **Yandex** 72 | 73 | ``` php 74 | Pinger::pingYandex('Title of post', 'http://url.of/your-post', 'http://url.of/your-rss(optional)'); 75 | ``` 76 | 77 | **Yahoo** 78 | 79 | ``` php 80 | Pinger::pingYahoo('Title of post', 'http://url.of/your-post', 'http://url.of/your-rss(optional)'); 81 | ``` 82 | 83 | **Feedburner** 84 | 85 | ``` php 86 | Pinger::pingFeedburner('Title of post', 'http://url.of/your-post', 'http://url.of/your-rss(optional)'); 87 | ``` 88 | 89 | **Weblogs** 90 | 91 | ``` php 92 | Pinger::pingWeblogs('Title of post', 'http://url.of/your-post', 'http://url.of/your-rss(optional)'); 93 | ``` 94 | 95 | **PingOMatic** 96 | 97 | ``` php 98 | Pinger::pingPingOMatic( 99 | 'Title of post', 100 | 'http://url.of/your-post', 101 | 'http://url.of/your-rss(optional)', 102 | [ 103 | 'additional' => 'params', 104 | 'to' => 'send', 105 | ]); 106 | ``` 107 | 108 | #### Ping any other service 109 | 110 | ``` php 111 | Pinger::ping('http://url.of/service', 'Title of post', 'http://url.of/your-post', 'http://url.of/your-rss(optional)'); 112 | ``` 113 | 114 | ## Further plans 115 | 116 | - clean the code 117 | - create driver system for different services 118 | 119 | ## Contributions 120 | 121 | Contributions are highly appreciated. 122 | 123 | Send your pull requests to `master` branch. 124 | 125 | 126 | ## License 127 | 128 | The MIT License (MIT). Please see [License File](https://github.com/garf/laravel-pinger/blob/master/LICENSE) for more information. 129 | 130 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "garf/laravel-pinger", 3 | "description": "Ping search engines about website updates", 4 | "keywords": ["laravel", "ping", "search engines", "google", "yahoo", "yandex", "bing", "pingomatic", "ping-o-matic"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Dinar Garipov", 9 | "email": "garipov.dinar@gmail.com" 10 | } 11 | ], 12 | "minimum-stability": "stable", 13 | "require": { 14 | "php": ">=5.4.0", 15 | "illuminate/support": ">=4.2" 16 | }, 17 | "autoload": { 18 | "psr-4": { 19 | "Garf\\LaravelPinger\\": "src/" 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pinger.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/garf/laravel-pinger/cd6c15936d04c2dd1add9444019fc0301cd83a97/pinger.jpg -------------------------------------------------------------------------------- /src/LaravelPingerServiceProvider.php: -------------------------------------------------------------------------------- 1 | loadViewsFrom(__DIR__.'/views', 'laravel-pinger'); 17 | $this->publishes([ 18 | __DIR__.'/config/config.php' => config_path('pinger.php'), 19 | ], 'config'); 20 | } 21 | 22 | /** 23 | * Register the application services. 24 | * 25 | * @return void 26 | */ 27 | public function register() 28 | { 29 | $this->registerLaravelPinger(); 30 | $this->app->alias('pinger', \Garf\LaravelPinger\Pinger::class); 31 | $this->mergeConfigFrom( 32 | __DIR__.'/config/config.php', 'pinger' 33 | ); 34 | } 35 | 36 | private function registerLaravelPinger() 37 | { 38 | $this->app->singleton('pinger', function ($app) { 39 | return new Pinger(); 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Pinger.php: -------------------------------------------------------------------------------- 1 | services = config('pinger.services'); 22 | } 23 | 24 | public function pingYandex($title, $url, $rss = null) 25 | { 26 | $xml = $this->getXml($title, $url, $rss); 27 | 28 | return $this->sendPing('http://ping.blogs.yandex.ru', $xml); 29 | } 30 | 31 | public function pingGoogle($title, $url, $rss = null) 32 | { 33 | $xml = $this->getXml($title, $url, $rss); 34 | 35 | return $this->sendPing('http://blogsearch.google.com/ping/RPC2', $xml); 36 | } 37 | 38 | public function pingYahoo($title, $url, $rss = null) 39 | { 40 | $xml = $this->getXml($title, $url, $rss); 41 | 42 | return $this->sendPing('http://api.my.yahoo.com/RPC2', $xml); 43 | } 44 | 45 | public function pingFeedburner($title, $url, $rss = null) 46 | { 47 | $xml = $this->getXml($title, $url, $rss); 48 | 49 | return $this->sendPing('http://ping.feedburner.com', $xml); 50 | } 51 | 52 | public function pingWeblogs($title, $url, $rss = null) 53 | { 54 | $xml = $this->getXml($title, $url, $rss); 55 | 56 | return $this->sendPing('http://ping.weblogs.se/', $xml); 57 | } 58 | 59 | public function pingPingOMatic($title, $url, $rss = null, $params = []) 60 | { 61 | $entity = [ 62 | 'chk_weblogscom' => 'on', 63 | 'chk_blogs' => 'on', 64 | 'chk_feedburner' => 'on', 65 | 'chk_newsgator' => 'on', 66 | 'chk_myyahoo' => 'on', 67 | 'chk_pubsubcom' => 'on', 68 | 'chk_blogdigger' => 'on', 69 | 'chk_weblogalot' => 'on', 70 | 'chk_newsisfree' => 'on', 71 | 'chk_topicexchange' => 'on', 72 | 'chk_google' => 'on', 73 | 'chk_tailrank' => 'on', 74 | 'chk_skygrid' => 'on', 75 | 'chk_collecta' => 'on', 76 | 'chk_superfeedr' => 'on', 77 | ]; 78 | 79 | $entity['title'] = urlencode($title); 80 | $entity['blogurl'] = urlencode($url); 81 | $entity['rssurl'] = urlencode($rss); 82 | 83 | $query_string = http_build_query(array_merge($entity, $params)); 84 | 85 | $service_url = 'http://pingomatic.com/ping/?'.$query_string; 86 | 87 | return $this->sendPing($service_url, $query_string); 88 | } 89 | 90 | public function ping($service_url, $title, $url, $rss = null) 91 | { 92 | $xml = $this->getXml($title, $url, $rss); 93 | 94 | return $this->sendPing($service_url, $xml); 95 | } 96 | 97 | public function pingAll($title, $url, $rss = null) 98 | { 99 | $xml = $this->getXml($title, $url, $rss); 100 | 101 | foreach ($this->services as $service) { 102 | $this->sendPing($service, $xml); 103 | } 104 | 105 | $this->pingPingOMatic($title, $url, $rss); 106 | 107 | return true; 108 | } 109 | 110 | private function getXml($title, $url, $rss = null) 111 | { 112 | $data = [ 113 | 'title' => $title, 114 | 'url' => $url, 115 | ]; 116 | if (!empty($rss)) { 117 | $data['rss'] = $rss; 118 | } 119 | 120 | return view('laravel-pinger::xml', $data)->render(); 121 | } 122 | 123 | private function sendPing($url, $post) 124 | { 125 | $ch = curl_init(); 126 | curl_setopt($ch, CURLOPT_URL, $url); 127 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 128 | curl_setopt($ch, CURLOPT_TIMEOUT, 3); 129 | curl_setopt($ch, CURLOPT_POST, 1); 130 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 131 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); 132 | $response = curl_exec($ch); 133 | curl_close($ch); 134 | 135 | return $response; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/PingerFacade.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'http://ping.blogs.yandex.ru', 6 | 'http://blogsearch.google.com/ping/RPC2', 7 | 'http://api.my.yahoo.com/RPC2', 8 | 'http://api.my.yahoo.com/rss/ping', 9 | 'http://ping.feedburner.com', 10 | 'http://ping.weblogs.se/', 11 | ], 12 | ]; 13 | -------------------------------------------------------------------------------- /src/views/xml.blade.php: -------------------------------------------------------------------------------- 1 | {!! '<'.'?xml' !!} version="1.0" encoding="UTF-8"?> 2 | 3 | weblogUpdates.ping 4 | 5 | 6 | {{ $title }} 7 | 8 | 9 | {{ $url }} 10 | 11 | @if(!empty($rss)) 12 | 13 | {{ $rss }} 14 | 15 | @endif 16 | 17 | --------------------------------------------------------------------------------