Version 1
[yaffs-website] / web / modules / contrib / media_entity_instagram / README.md
1 ## About Media entity
2
3 Media entity provides a 'base' entity for a media element. This is a very basic
4 entity which can reference to all kinds of media-objects (local files, YouTube
5 videos, tweets, CDN-files, ...). This entity only provides a relation between
6 Drupal (because it is an entity) and the resource. You can reference to this
7 entity within any other Drupal entity.
8
9 ## About Media entity Instagram
10
11 This module provides Instagram integration for Media entity (i.e. media type provider
12 plugin).
13
14 ### Without Instagram API
15 If you need just to embembed instagrams you can use this module without using Instagram's API. That will give you access to the shortcode field available from the url/embed code.
16
17 You will need to:
18
19 - Create a Media bundle with the type provider "Instagram".
20 - On that bundle create a field for the Instagram url/source (this should be a plain text or link field).
21 - Return to the bundle configuration and set "Field with source information" to use that field.
22
23 **IMPORTANT:** beware that there is limit on the number of request that can be made for free. [Read more](http://instagram.com/developer/endpoints/)
24
25
26 ### With Instagram API
27 If you need to get other fields, you will need to use Instagram's API. To get this working follow the steps below:
28
29 - Download and enable [composer_manager](https://www.drupal.org/project/composer_manager). Also make sure you have [drush](https://github.com/drush-ops/drush) installed.
30 - Run the following commands from within your Drupal root directory to download the [library](https://github.com/galen/PHP-Instagram-API) that will handle the communication:
31
32 ```
33   // Rebuild the composer.json file with updated dependencies.
34   $ drush composer-json-rebuild
35
36   // Install the required packages.
37   $ drush composer-manager install
38 ```
39 - Create a instagram app on the instagram [developer site](http://instagram.com/developer/register/)
40 - Enable read access for your instagram app
41 - Grab your client ID from the instagram developer site
42 - In your Instagram bundle configuration set "Whether to use Instagram api to fetch instagrams or not" to "Yes"" and paste in the "Client ID"
43
44 **NOTE:** We are currently using a patched version of the library with the ability to get the media by shortcode. This is the pull request for it: https://github.com/galen/PHP-Instagram-API/pull/46/files
45
46 ### Storing field values
47 If you want to store the fields that are retrieved from Instagram you should create appropriate fields on the created media bundle (id) and map this to the fields provided by Instagram.php.
48
49 **NOTE:** At the moment there is no GUI for that, so the only method of doing that for now is via CMI.
50
51 This would be an example of that (the field_map section):
52
53 ```
54 langcode: en
55 status: true
56 dependencies:
57   module:
58     - media_entity_instagram
59 id: instagram
60 label: Instagram
61 description: 'Instagram photo/video to be used with content.'
62 type: instagram
63 type_configuration:
64   source_field: link
65   use_instagram_api: '1'
66   client_id: YOUR_CLIENT_ID
67 field_map:
68   id: instagram_id
69   type: instagram_type
70   thumbnail: instagram_thumbnail
71   username: instagram_username
72   caption: instagram_caption
73   tags: instagram_tags
74 ```
75
76 Project page: http://drupal.org/project/media_entity_instagram
77
78 Maintainers:
79  - Janez Urevc (@slashrsm) drupal.org/user/744628
80  - Malina Randrianavony (@designesse) www.drupal.org/user/854012
81
82 IRC channel: #drupal-media