PHPackages                             yugo/blogger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. yugo/blogger

AbandonedLibrary[API Development](/categories/api)

yugo/blogger
============

Blogger Rest API

v1.1.0(7y ago)7312MITPHP

Since Feb 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/yugo412/blogger)[ Packagist](https://packagist.org/packages/yugo/blogger)[ RSS](/packages/yugo-blogger/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Blogger API for Laravel
=======================

[](#blogger-api-for-laravel)

Unoffical Blogger (REST API) package for Laravel.

Features
--------

[](#features)

- Get blog information.
- Retrieve posts.
- Retrieve post by ID or path.
- Search posts.
- Retrieve pages.
- Retrieve single page.

Installation
------------

[](#installation)

Add Blogger package to your Laravel application by running command:

```
composer require yugo/blogger

```

Configuration
-------------

[](#configuration)

If you are using Laravel 5.5 and upper, provider is automatically registered using auto package discovery from Laravel. If you get error to indicate provider not found, you can register new provider via `config/app.php` file.

```
/*
 * Package Service Providers...
 */
Yugo\Blogger\BloggerServiceProvider::class,

```

You can set up alias for Blogger package from the same config file.

```
// facade alias
'Blogger' => Yugo\Blogger\Facades\Blogger::class,

```

Before using `Blogger` facade, you must provide API key and full URL from your blog. API Key can be generated via [this url](https://developers.google.com/blogger/docs/3.0/using#APIKey).

Add two configs called `key` and `url` to file `config/services.php`.

```
'blogger' => [
    'key' => env('BLOGGER_KEY'),
    'url' => env('BLOGGER_URL', 'https://yourblog.blogspot.com'),
],

```

For security reason, you can define `blogger.key` and `blogger.url` config from `.env` file using sample below.

```
BLOGGER_KEY="secret-api-key"
BLOGGER_URL="https://yourblog.blogspot.com"

```

Usage
-----

[](#usage)

Before retrieving posts, pages, and comments, you must know your blog id first. To retrieve blog id data, you can use `blog` method from `Blogger` facade. For example:

```
$blog = Blogger::blog();

```

Available Methods
-----------------

[](#available-methods)

```
$blog = Blogger::blog();

// retrieving posts
$posts = Blogger::posts($blog['id']);
$posts = Blogger::search($keyword, $blogId);
$post = Blogger::postById($postId, $blogId);
$post = Blogger::postByPath($path, $blogId);

// retrieving pages
$pages = Blogger::pages($blog['id']);
$page = Blogger::page($pageId, $blogId);
```

If you want to include images in post, you can chain method `withImages(bool $withImages = true)`, for example:

```
$posts = Blogger::withImages()->posts();
```

Best Practice
-------------

[](#best-practice)

When you retrieving posts or pages, you must define blog id in every method. If you only have one blog and static blog id, you can follow this sample code for best practice.

```
