Drupal 7 开发内部培训资料, 分头诗人

我手写了一个services,但是出现了错误 401 Unauthorized : Missing required argument param

赞成!
0
否决!
function app_services_services_resources()
{
        $resources = array(
            'app_services_resources' => array(
                'actions' => array(
                    'get_user_name' => array(
                        'help' => t('Gets user email of uid passed.'),
                        'file' => array(
                            'type' => 'inc',
                            'module' => 'app_services',
                            'name' => 'app_services.resource',
                        ),
                        'callback' => 'app_services_get_user_name',
                        'args' => array(
                            array(
                                'name'         => 'param',
                                'type'         => 'array',
                                'description'  => t(' uid to pass.'),
                                'source'       => 'data',
                                'optional'     => FALSE,
                            ),
                        ),
                        'access callback' => TRUE,
                        /*
                        'access callback file' => array(
                            'type' => 'inc',
                            'module' => 'drupalgap',
                            'name' => 'drupalgap.resource',
                        ),
                        'access arguments' => array('access user profiles'),*/
                       // 'access arguments append' =>false,

                    ),
                ),
            ),
        );
        return $resources;

}

function app_services_get_user_name($param) {

    return $param;
}

1 个回答

赞成!
0
否决!

试一下下面改动

'args' => array(
                            array(
                                'name'         => 'param',
                                'type'         => 'array',
                                'description'  => t(' uid to pass.'),
                                'source'       => 'data',
                                'optional'     => FALSE,
                            ),
                        ),

 

改成

'args' => array(

                                'name'         => 'param',
                                'type'         => 'array',
                                'description'  => t(' uid to pass.'),
                                'source'       => 'data',
                                'optional'     => FALSE,
  ),