I have been searching for a D7 module that makes the Google API PHP client available, preferably with the libraries module. I have found the googleapilibs module but this only provides access to the AJAX libraries and is outdated.
So i have been looking for a way to implement this myself and eventually share a full module for others to use. I am trying to figure out what would be the best approach for this. I hope you can find some time to help me with this.
The Google API PHP library makes it possible to interact with Google Services such as Analytics, Calendar, Fusion Tables, Maps, YouTube and many more. There are multiple client libraries available for .NET, Java, Python Ruby and obviously PHP. The Client library is a package containing the Google_Client.php and a seperate code file for each service, for instance 'Google_YouTubeService.php'. So when i want to use a specific service i need both the Client and the Service PHP file loaded.
The PHP Client library can be downloaded here : http://code.google.com/p/google-api-php-client/
The directory structure of the library is as follows:
Main Google Client PHP file.
Services PHP files.
Option 1: Full package
My first idea was to put everything in one hook_libraries_info() implementation and create a seperate $libraries['name'] element for each service. Here i get stuck with array key needing to be the folder name in sites/all/libraries which i cannot re-use. Creating a $libraries['youtube-data-api'] would mean i have to create a copy of the full API in sites/all/libraries. Then i checked to documentation and saw the "variants" option. I could create a $libraries['google-api-php-client'] array which points to the Google_Client.php and create variants for each service. This would probably work but it feels as if i am using variants all wrong. So the option for a full package pretty much ends there. Obviously i can create $libraries['google-api-php-client'] and add all PHP files to the files > php array, but that would mean the PHP files for all services would be loaded all the time.
Option 2: Module with submodules
My second option would be creating a 'master' module for the Google API client and a seperate module for each service. I could then use the 'integration files' array to add the PHP files for specific services. I'm curious however if this would load files within the modules directory or if this would load additional files within the library. Since the library also contains a few configuration files and tools (such as Oath2 implementation) i don't want to copy files into a seperate module directory. Also i wonder what will happen when i add integration files for modules that are disabled.
I hope you can shed your light on this and give me some tips on how to tackle this.