Giter Site home page Giter Site logo

media_entity_twitter's Introduction

Build Status

About Media entity

Media entity provides a 'base' entity for a media element. This is a very basic entity which can reference to all kinds of media-objects (local files, YouTube videos, tweets, CDN-files, ...). This entity only provides a relation between Drupal (because it is an entity) and the resource. You can reference to this entity within any other Drupal entity.

About Media entity Twitter

This module provides Twitter integration for Media entity (i.e. media type provider plugin).

Without Twitter API

If you need just to embembed tweets you can use this module wihout using Twitter's API. That will give you access to the fields available from the url/embed code: id and user.

You will need to:

  • Create a Media bundle with the type provider "Twitter".
  • On that bundle create a field for the Tweet url/source (this should be a plain text or link field).
  • Return to the bundle configuration and set "Field with source information" to use that field.

IMPORTANT: beware that there is limit on the number of request that can be made for free. Read more

With Twitter API

If you need to get other fields, you will need to use Twitter's API. To get this working follow the steps below:

  • Download and enable composer_manager. Also make sure you have drush installed.
  • Run the following commands from within your Drupal root directory to download the library that will handle the communication:
  // Rebuild the composer.json file with updated dependencies.
  $ drush composer-json-rebuild

  // Install the required packages.
  $ drush composer-manager install
  • Create a twitter app on the twitter developer site
  • Enable read access for your twitter app
  • Grab your access tokens from the twitter developer site
  • In your Twitter bundle configuration set "Whether to use Twitter api to fetch tweets or not" to "Yes"" and paste in the "Consumer key", "Consumer secret", "Oauth access token" and the "Oauth access token secret"

Storing field values

If you want to store the fields that are retrived from Twitter you should create appropriate fields on the created media bundle (image, content and retweet_count) and map this to the fields provided by Twitter.php.

NOTE: At the momemnt there is no GUI for that, so the only method of doing that for now is via CMI.

This whould be an example of that (the field_map section):

langcode: en
status: true
dependencies:
  module:
    - media_entity_twitter
id: tweet
label: Tweet
description: 'Tweet to be used with content.'
type: twitter
type_configuration:
  twitter:
    source_field: field_tweet_source
    use_twitter_api: '1'
    consumer_key: YOUR_CONSUMER_KEY
    consumer_secret: YOUR_CONSUMER_SECRET
    oauth_access_token: YOUR_OAUTH_ACCESS_TOKEN
    oauth_access_token_secret: YOUR_OAUTH_ACCESS_TOKEN_SECRET
field_map:
  source: field_tweet_source
  id: field_tweet_id
  content: field_tweet_content

Project page: http://drupal.org/project/media_entity_twitter

Maintainers:

  • Janez Urevc (@slashrsm) drupal.org/user/744628
  • Primož Hmeljak (@primsi) drupal.org/user/282629

IRC channel: #drupal-media

media_entity_twitter's People

Contributors

slashrsm avatar primsi avatar nkgokul avatar marcingy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.