This following is my resource:

For clearly read, I delete some line.

 * Implementation of hook_services_resources().

function baidu_push_services_services_resources() {
  $resources = array();

  $resources['message']['actions']['send'] = [
    'file' => array(
      'type' => 'inc',
      'module' => 'baidu_push_services',
      'name' => 'baidu_push_services',
    'access callback' => '_message_access',
    'callback' => 'baidu_push_services_send',
    'args' => array(
        'name' => 'uid',
        'type' => 'string',
        'source' => 'data',
        'optional' => FALSE,

  return $resources;

In order to test my 'access callback' function will be invoked, I always return FALSE in my 'access callback' function:

function _message_access($op = 'view', $args = array()) {
  return FALSE;

But when I try to use curl command line to test with no SESSION and no Token, but It work!(return the right result to me), Did that mean 'access callback' not be invoked?

So I try to use drush cc all to clear cache, But still above problem.

  • Are you working with a permission hook? Are you calling curl with authentication or can your service be accessed by anonymous? I'm guessing it's a permission problem?
    – Kevin
    Mar 12, 2014 at 15:37

1 Answer 1


Is your access callback in the same file? If not, you'd have to add: "access callback file" to your definition, and point to it.

I'd also clear cache within Drupal, as I've seen drush cc all not always clear all caches.

Also, I'd name-space your access callback function, as it could be conflicting with something else in the system. _message_access is a pretty generic name. You should rename it to: _baidu_push_services_message_access().

Otherwise, your syntax looks correct.

Or, if you solved your issue, perhaps post it in here, to help others.

  • thanks for your help, I am try to re-download new drupal and services module, and put my code in, but still not work. So, I am consider i should switch to another language/framework?
    – Moon soon
    Jul 18, 2014 at 1:21
  • access callback in the same file? yes!
    – Moon soon
    Jul 18, 2014 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.