I have a have setup a custom endpoint via services and a REST server the custom end point looks like this,
https://website.local/api/v1/druaplsquare
The custom endpoint is built using the following code,
drupalsqaure.module
function drupalsquare_services_resources() {
$resources = array();
$resources['drupalsquare'] = array(
'operations' => array(
'create' => array(
'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/drupalsquare'),
'callback' => '_job_resource_create',
'args' => array(
array(
'name' => 'node',
'optional' => FALSE,
'source' => 'data',
'description' => 'The node data to create',
'type' => 'array',
),
),
'access callback' => '_drupalsquare_resource_access'
),
'delete' => array(
'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/drupalsquare'),
'callback' => '_job_resource_delete',
'args' => array(
array(
'name' => 'jobref',
'optional' => FALSE,
'source' => array('path' => 0),
'description' => 'The job reference to delete',
'type' => 'string',
),
),
'access callback' => '_drupalsquare_resource_access'
),
),
);
return $resources;
}
resources/drupalsquare.inc
<?php
function _drupalsquare_resource_access() {
return TRUE;
}
//function _drupalsquare_resource_retrieve($uid) {
// $account = user_load($uid);
//
// if (isset($account->data['checked_in'])) {
// return array(
// 'uid' => $account->uid,
// 'name' => $account->name,
// 'last_checkin' => $account->data['checked_in'],
// );
// }
// else {
// return FALSE;
// }
//}
function _drupalsquare_resource_checkin($JobReference, $date = NULL) {
die(print_r($JobReference));
// $account = user_load($uid);
// $account->data['checked_in'] = is_null($date) ? REQUEST_TIME : $date;
// user_save($account);
return TRUE;
}
function _job_resource_create() {
die("create");
}
function _job_resource_delete($jobref) {
die("here");
}
I am making a cURL request this is endpoint, but I am first of all authenticating a user, and getting a token, I am then sending this token in the request header, however the endpoint above is returning,
Access denied for user anonymous
Can anyone see any reason as why this would be happening?