The DrupalGap module and mobile application starter kit can be customized to build mobile apps to communicate with Drupal websites. DrupalGap is built around PhoneGap (Cordova) and utilizes the power of jQuery, jQueryMobile, and of course Drupal.
DrupalGap Module Installation (via Drush, for advanced users)
// Drupal 7
# drush dl drupalgap services libraries views_datasource
// Drupal 6
# drush dl drupalgap services libraries views_datasource autoload
// Download spyc.php for the Rest Server.
# cd sites/all/modules/services/servers/rest_server/lib
// (Unix, Linux)
# wget http://spyc.googlecode.com/svn/trunk/spyc.php -O spyc.php
# curl http://spyc.googlecode.com/svn/trunk/spyc.php -o spyc.php
// Enable DrupalGap.
# drush en drupalgap
Then go to your Drupal site and verify DrupalGap was enabled properly:
Now you're ready to try the DrupalGap Mobile Application.
DrupalGap Module Installation
1. Download the DrupalGap module and upload it to your 'sites/all/modules' directory.
2. Download The DrupalGap Module Dependencies
- Views JSON (included in the Views Datasource module)
- REST Server* (included in the Services module)
*Before the REST Server module can be enabled, you need to download SPYC and upload the spyc.php file to your drupal site so it lives here, for example:
3. Enable the DrupalGap module dependencies listed above.
4. Enable the DrupalGap module.
5. Flush all of your Drupal caches.
6. Visit admin/config/drupalgap in D7 (or admin/settings/drupalgap in D6) and verify the module was enabled properly.
7. You're ready to try the DrupalGap Mobile Application.
DrupalGap Module Installation Troubleshooting
When DrupalGap is enabled, it automatically creates a Service Endpoint and enables a few Service Resources. Let's verify these were automatically setup correctly.
1. Service Endpoint - Visit admin/structure/services and verify the 'drupalgap' Endpoint is listed in the table, and verify it is enabled.
2. Service Endpoint Settings - Visit admin/structure/services/list/drupalgap and verify the following settings:
- Server: REST
- Path to endpoint: drupalgap
- Debug mode enabled: optional
- Session authentication: checked
3. Service Resources - Visit admin/structure/services/list/drupalgap/resources and verify all drupalgap_* Resources are enabled.
4. REST Server - Visit admin/structure/services/list/drupalgap/server and verify these settings are enabled:
5. The SPYC dependancy for the Rest Server has some known issues.
Manually Confirm Services Are Set Up Properly With The Firefox Poster Plugin
If visiting admin/config/drupalgap throws an error, and the trouble shooting topics above do not work, then as a last resort, we can use the Firefox Poster Plugin to make sure the DrupalGap Service Endpoint is set up properly.
Open up the Poster plugin for Firefox:
- URL: http://www.example.com/?q=drupalgap/system/connect.json
- Content Type: application/x-www-form-urlencoded
- Actions: POST
Once you fill out the 'URL' and 'Content Type' fields, click the 'POST' button in the 'Actions' section. A Response window with a status of '200 OK' should show up if everything worked correctly. You should get a JSON response similar to the following:
As you can see, the System Connect resource returns JSON with some information about the currently connected user.
Make sure the www/index.html file in PhoneGap is pointing to the correct version of your Cordova JS file, as well as the correct versions of your downloaded jQuery and jQueryMobile.
Common Error Messages
Error: "Not found: Could not find the controller."
If you receive this error, this means one of two things
- The Service Resource is not Enabled for Your Service Endpoint (admin/structure/services)
- Your HTTP Method for Accessing the Service Resource is Incorrect. (GET, POST, PUT, DELETE)
DrupalGap API Error
- parsererror (SyntaxError: Unable to parse JSON string) [OK] - Disable the "Views API Mode" under "Settings" in the "Format" section for your "JSON Data Document" view (views datasource, views json).
DrupalGap User Permissions
There are a few permissions that should be enabled to take full advantage of the features within DrupalGap:
- Save file information (authenticated user)
- Get a system variable (anonymous user, authenticated user)