Community Documentation

DrupalGap Documentation

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 drupalgap

Then go to your Drupal site and verify DrupalGap was enabled properly:

D7: admin/config/drupalgap
D6: admin/settings/drupalgap

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

Drupal 7

Drupal 6

*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:

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

  1. The Service Resource is not Enabled for Your Service Endpoint (admin/structure/services)
  2. 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.

Page status

Needs updating

Log in to edit this page

About this page

Drupal version
Drupal 6.x, Drupal 7.x
Audience
Programmers
Level
Intermediate, Advanced
Keywords
drupalgap, jquerymobile, phonegap
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.