percipiolondon/craft-tweet-feed 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

percipiolondon/craft-tweet-feed

最新稳定版本:4.2.0

Composer 安装命令:

composer require percipiolondon/craft-tweet-feed

包简介

Get the latest tweets from a Twitter handle with your own design

README 文档

README

Get the latest tweets from a Twitter handle with your own design

Screenshot

Requirements

This plugin requires Craft CMS 3.5.0 or later. We utilise Guzzle 6 and up (7 included) and Twitter v2.0.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Tell Composer to load the plugin:

     composer require percipiolondon/craft-tweet-feed
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Tweet.

Tweet Feed Overview

This plugin provides a Twitter feed from a specific Twitter handle.

Configuring Tweet Feed

To make this happen, you need to make an app in the Developers Portal. Make sure it's not a standalone app because we use the Twitter API 2.0.

Create your keys and tokens and paste them into the plugin settings page. Make sure you create an OAuth 1.0a and generate the access tokens.

Besides the keys and tokens, we also require the Twitter user id to provide the tweets from a specific handle. If you don't know the id, you can look it op on this site.

You can provide all of this inside of your environment file.

Screenshot

Using Tweet Feed

To make use of Tweet Feed, we created a Craft variable to fetch.

The craft.tweetfeed.tweets() function can have 3 parameters.

First param: amount of results (default: 100)

The first one will ask for the number of results you want to receive. There's a maximum of 100 results that can be fetched. Here's a list of all the Twitter API v2 rate limits.

example: 3

Second param: types of fields (default: null)

The types of fields are the data you want to receive from Twitter. By default, the id and text are provided. We also add the entities so you can already use the tweet url. To know all the options, you can visit the Tweet object page.

Always provide the list with a comma as separation.

example: author_id,context_annotations

Third param: extra parameters (default: '')

If you want to extend the query, you can add extra parameters to the url. The max_results and tweet.fields are already used in the previously shown parameters. To know which kind of parameters excists, you can visit the GET /2/users/:id/tweets page and scroll to 'Query parameters'.

To provide these parameters for our plugin, use the following example. You can tie parameters to each other by using &.

example: &exclude=retweets,replies&user.fields=id

Twig example

{% set tweets = craft.tweetfeed.tweets(3,'author_id,context_annotations','&exclude=retweets,replies&user.fields=id') %}

{% for tweet in tweets %}
   <div>
       <h3>{{ tweet.text }}</h3>
   </div>
{% endfor %}

urlify twig extension filter

If you want to parse the URLs and hashtags into clickable urls, you can use the | urlify filter. You need to pass down the full object to get the filtered tweet text back.

{% set tweets = craft.tweetfeed.tweets(3,'author_id,context_annotations','&exclude=retweets,replies&user.fields=id') %}

{% for tweet in tweets %}
   <div>
       <h3>{{- tweet | urlify | raw -}}</h3>
   </div>
{% endfor %}

Use cache tag to reduce calls

There is a limit on API calls per day. If you have a high traffic site, we recommend using the cache tag from CraftCMS to reduce calls.

For example:

{% cache for 1 day %}
   {% set tweets = craft.tweetfeed.tweets(3,'author_id,context_annotations','&exclude=retweets,replies&user.fields=id') %}
   
   {% for tweet in tweets %}
      <div>
          <h3>{{ tweet.text }}</h3>
      </div>
   {% endfor %}
{% endcache %}

Tweet Feed Roadmap

Some updates to do and ideas for potential features:

  • GQL support

Brought to you by percipiolondon

percipiolondon/craft-tweet-feed 适用场景与选型建议

percipiolondon/craft-tweet-feed 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 672 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cms」 「twitter」 「tweets」 「Craft」 「craftcms」 「craft-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 percipiolondon/craft-tweet-feed 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 percipiolondon/craft-tweet-feed 我们能提供哪些服务?
定制开发 / 二次开发

基于 percipiolondon/craft-tweet-feed 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 672
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-17