Further modules included.
[yaffs-website] / web / modules / contrib / media_entity_twitter / README.md
1 [![Build Status](https://travis-ci.org/drupal-media/media_entity_twitter.svg?branch=8.x-1.x)](https://travis-ci.org/drupal-media/media_entity_twitter)
2
3 ## About Media entity
4
5 Media entity provides a 'base' entity for a media element. This is a very basic
6 entity which can reference to all kinds of media-objects (local files, YouTube
7 videos, tweets, CDN-files, ...). This entity only provides a relation between
8 Drupal (because it is an entity) and the resource. You can reference to this
9 entity within any other Drupal entity.
10
11 ## About Media entity Twitter
12
13 This module provides Twitter integration for Media entity (i.e. media type
14 provider plugin).
15
16 ### Without Twitter API
17 If you need just to embedded tweets you can use this module without using
18 Twitter's API. That will give you access to the fields available from the
19 url/embed code: id and user.
20
21 You will need to:
22
23 - Create a Media bundle with the type provider "Twitter".
24 - On that bundle create a field for the Tweet url/source (this should be a plain
25   text or link field).
26 - Return to the bundle configuration and set "Field with source information" to
27   use that field.
28
29 **IMPORTANT:** beware that there is limit on the number of request that can be
30 made for free. [Read more](https://dev.twitter.com/rest/public)
31
32
33 ### With Twitter API
34 If you need to get other fields, you will need to use Twitter's API. To get this
35 working follow the steps below:
36
37 - Download and enable 
38   [composer_manager](https://www.drupal.org/project/composer_manager). Also make
39   sure you have [drush](https://github.com/drush-ops/drush) installed.
40 - Run the following commands from within your Drupal root directory to download
41   the [library](https://github.com/J7mbo/twitter-api-php) that will handle the
42   communication:
43
44 ```
45   // Rebuild the composer.json file with updated dependencies.
46   $ drush composer-json-rebuild
47
48   // Install the required packages.
49   $ drush composer-manager install
50 ```
51 - Create a twitter app on the twitter
52   [developer site](https://dev.twitter.com/apps/)
53 - Enable read access for your twitter app
54 - Grab your access tokens from the twitter developer site
55 - In your Twitter bundle configuration set "Whether to use Twitter api to fetch
56   tweets or not" to "Yes"" and paste in the "Consumer key", "Consumer secret",
57   "Oauth access token" and the "Oauth access token secret"
58
59 ### Storing field values
60 If you want to store the fields that are retrieved from Twitter you should create
61 appropriate fields on the created media bundle (image, content and
62 retweet_count) and map this to the fields provided by Twitter.php.
63
64 **NOTE:** At the moment there is no GUI for that, so the only method of doing
65 that for now is via CMI.
66
67 This would be an example of that (the field_map section):
68
69 ```
70 langcode: en
71 status: true
72 dependencies:
73   module:
74     - media_entity_twitter
75 id: tweet
76 label: Tweet
77 description: 'Tweet to be used with content.'
78 type: twitter
79 type_configuration:
80   twitter:
81     source_field: field_tweet_source
82     use_twitter_api: '1'
83     consumer_key: YOUR_CONSUMER_KEY
84     consumer_secret: YOUR_CONSUMER_SECRET
85     oauth_access_token: YOUR_OAUTH_ACCESS_TOKEN
86     oauth_access_token_secret: YOUR_OAUTH_ACCESS_TOKEN_SECRET
87 field_map:
88   source: field_tweet_source
89   id: field_tweet_id
90   content: field_tweet_content
91 ```
92
93 Project page: http://drupal.org/project/media_entity_twitter
94
95 Maintainers:
96  - Janez Urevc (@slashrsm) drupal.org/user/744628
97  - Primož Hmeljak (@primsi) drupal.org/user/282629
98
99 IRC channel: #drupal-media