Last updated March 26, 2013. Created by tyler.frankenstein on May 28, 2012.
Edited by s.Daniel, choster. Log in to edit this page.
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
// (OSX)
# curl http://spyc.googlecode.com/svn/trunk/spyc.php -o spyc.php
// Enable DrupalGap.
# drush en drupalgapThen go to your Drupal site and verify DrupalGap was enabled properly:
D7: admin/config/drupalgap
D6: admin/settings/drupalgapNow 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
Drupal 7
- Views JSON (included in the Views Datasource module)
- REST Server* (included in the Services module)
Drupal 6
- Views JSON (included in the Views Datasource module)
- REST Server* (included in the Services module)
- Autoload
*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:
sites/all/modules/services/servers/rest_server/lib/spyc.php
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:
Response formatters:
- json
Request parsing:
- application/json
- application/x-www-form-urlencoded
- multipart/form-data
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:
{
"sessid":"abcdefghijklmnopqrstuvwxy",
"user":{
"uid":0,
"hostname":"127.0.0.1",
"roles":{
"1":"anonymous user"
},
"cache":0,
"session":"",
"timestamp":"1321994670"
}
}As you can see, the System Connect resource returns JSON with some information about the currently connected user.
index.html
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:
- Services
-
- Save file information (authenticated user)
- Get a system variable (anonymous user, authenticated user)
Comments
Error: "Not found: Could not find the controller."
I'm getting this error. I know the service resource is enabled so I'm guessing it must be the second problem, but I don't know what that means and can't find any information about it.
Please submit a support
Please submit a support request issue to the issue queue for help on this. We need much more information about your request to accurately debug this.