Providers query webservices like Facebook, Google+, Flickr, YouTube, Twitter, etc, and import the items returned from API calls as nodes in your Drupal site. There are many advantages to this:
-
You have complete control over the design of these items. For example, if you have a Twitter widget, Twitter’s branding will appear around the widget. If instead you use a Twitter provider then you can create your own templates in Drupal to display tweets however you want.
-
If a webservice becomes unavailable you will still be able to display content imported from that service.
-
You won’t need to include external Javascripts or make API calls with each page load. This will speed up the page load time on your site.
-
You can order, filter, and display content in ways that an API may not allow.
This module only acts as an API for other modules to implement. The next section lists providers that have been created.
Drupal: https://drupal.org/sandbox/jtrost/2049661 Github: https://github.com/jtrost/provider_youtube
Creating a new provider has 3 parts: Defining the provider, querying the API, and saving nodes for each item returned by the API. This module creates two hooks: hook_fetch_provider() and hook_set_provider_types(). The easiest way to create a provider is to use the [YouTube Provider module as a boilerplate](github.com/jtrost/provider_youtube/blob/master/provider_youtube.module).
-
[Define the provider](github.com/jtrost/provider_youtube/blob/master/provider_youtube.module#L100-L117).
-
[Create a curl function](github.com/jtrost/provider_youtube/blob/master/provider_youtube.module#L122-L129).
-
[Create a function that assigns the data from each item to fields in the content type](github.com/jtrost/provider_youtube/blob/master/provider_youtube.module#L69-L95).
-
Implement hook_fetch_provider(). This function is responsible for running the provider.
-
[Load the provider](github.com/jtrost/provider_youtube/blob/master/provider_youtube.module#L7).
-
[Build an URL to curl](github.com/jtrost/provider_youtube/blob/master/provider_youtube.module#L10).
-
[Run the curl and create new nodes for each item](github.com/jtrost/provider_youtube/blob/master/provider_youtube.module#L17-L42).
-
Create reporting / user feedback to let the user know the import was successful.
-