In the last few months we have been working on the Social API project which tries to harmonize Social Networking functionality in Drupal. This project is divided in four main components which are:
- Social API: contains the basic and generic methods, routing settings, and permissions every Social API sub-module will need
- Social Auth: implements methods and templates that will be used by login-related modules
- Social Post: provides methods to allow autoposting to social network’s accounts
- Social Widgets: allows sub-modules to add functionality to add widgets (like buttons, embedded content) to node, blocks, etc.
In this series, I will be showing a real-life example to implement an integration for Social Auth. This series will be based on the Social Auth Google module.
Getting your hands dirty: .info.yml and composer.json files
To start, we have to let Drupal know that our module depends on the Social Auth module. Furthermore, as this module authenticates with Google, we need to define the dependency (Google API PHP Client), using a composer.json file
In this example we use the Google PHP client; however, if you plan to work on an implementer for Twitter, you should look for the appropriate SDK. Make sure to implement official libraries if possible.
Now using Composer Manager, you can let Drupal download the library dependency you defined in the composer.json file. There is a description of this process in step 3 and 4 of this documentation page.