elloro/craft-social-feed
最新稳定版本:5.0.0
Composer 安装命令:
composer require elloro/craft-social-feed
包简介
Display social media feeds in Craft templates.
README 文档
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
统计信息
- 总下载量: 169
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-29