elloro / craft-social-feed
Display social media feeds in Craft templates.
Installs: 162
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Type:craft-plugin
pkg:composer/elloro/craft-social-feed
Requires
- php: >=8.1
- ext-json: *
- craftcms/cms: ^5.0
- guzzlehttp/guzzle: ^6.0|^7.0
- kevinrob/guzzle-cache-middleware: ^6.0
- psr/simple-cache: ^2.0|^3.0
- symfony/cache: ^6.0|^7.0
Requires (Dev)
- craftcms/phpstan: dev-main
README
Display social media feeds in Craft templates.
Requirements
- Craft CMS ^5.0
- PHP >= 8.1
- ext-json
Installation
Install via Composer:
composer require elloro/craft-social-feed
Then install the plugin from the Craft CMS control panel under Settings > Plugins, or via the CLI:
php craft plugin/install social-feed
Configuration
The plugin requires an API key for the social feed service. Create a config/social-feed.php file:
<?php return [ 'apiKey' => getenv('SOCIAL_FEED_API_KEY'), 'pageId' => getenv('SOCIAL_FEED_PAGE_ID'), ];
Add the following to your .env file:
SOCIAL_FEED_API_KEY=
SOCIAL_FEED_PAGE_ID=
The plugin connects to the API at https://social.elloro.nl. You can verify your API key by making a test request:
export SOCIAL_FEED_API_KEY=your-api-key export SOCIAL_FEED_PAGE_ID=your-page-id curl -H "X-AUTH-TOKEN: $SOCIAL_FEED_API_KEY" https://social.elloro.nl/api/social_pages/$SOCIAL_FEED_PAGE_ID/posts
Usage
The plugin exposes a craft.socialFeed template variable with a getPosts method.
{% set pageId = getenv('SOCIAL_FEED_PAGE_ID') %}
{% if items is not defined %}
{% set items = craft.socialFeed.getPosts(pageId, {'limit': 8}) %}
{% endif %}
{% for post in items %}
<article>
{{ post.content }}
</article>
{% endfor %}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
pageId |
mixed | Yes | The ID of the social media page |
params |
array | No | Query parameters (see below) |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
order |
string | Sort order: "ASC" or "DESC" |
limit |
integer | Maximum number of posts to return |
offset |
integer | Number of posts to skip (for pagination) |
Caching
API responses are cached for 15 minutes using a filesystem-based cache stored in Craft's runtime directory. No additional configuration is needed.
License
MIT