https://github.com/statamic/twitter
Twitter example addon for Statamic 3.
https://github.com/statamic/twitter
Last synced: 11 days ago
JSON representation
Twitter example addon for Statamic 3.
- Host: GitHub
- URL: https://github.com/statamic/twitter
- Owner: statamic
- Created: 2019-03-14T19:54:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-14T20:25:25.000Z (over 6 years ago)
- Last Synced: 2025-03-22T04:41:27.494Z (3 months ago)
- Language: JavaScript
- Size: 1.59 MB
- Stars: 5
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
> A fieldtype for Statamic v3

## Installation
```
composer require statamic/twitter
php artisan vendor:publish --provider="Statamic\Twitter\ServiceProvider"
```### Adding API Keys
This addon uses the [Jonathan Thuau's Twitter package](https://github.com/thujohn/twitter) under the hood. You will need to [create a Twitter app](https://apps.twitter.com/) and hook your API keys.
Once you've made your app, add the following to your `.env` file and enter the values:
```
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_ACCESS_TOKEN=
TWITTER_ACCESS_TOKEN_SECRET=
```## Fieldtype
Use the `twitter` fieldtype to select tweets from a given user.
``` yaml
fields:
-
handle: tweets
field:
type: twitter
max_items: 3
screen_name: jason_varga
```The fieldtype will save a list of tweet status IDs.
``` yaml
tweets:
- 12345
- 67890
```## Templating
The saved tweet IDs will be automatically augmented to useful data. Just use an array syntax to loop over them.
``` html
{{ tweets }}
{{ text }}
– {{ user }}
{{ /tweets }}
```