Hi First thing you have to do is
STEP 1: create a custom module and implement hook_services_resources()
EXAMPLE:
function mymodule_services_resources() {
return array(
'search' => array(
'create' => array(
'help' => 'Search for a content',
'file' => array('file' => 'inc', 'module' => 'your module name'),
'callback' => '_function_to_call_when_this_service_is_called',
'access callback' => 'user_access',
'access arguments' => array('access content'),
'access arguments append' => FALSE,
'args' => array(
array(
'name' => 'data',
'type' => 'struct',
'description' => 'The id of the data to get',
'source' => 'data',
'optional' => FALSE,
),
),
),
),
);
}
STEP 2: go to
Structure -> services
and enable your module
STEP 3: sending data to the client
$data - data sent to client it should be array
$url = $base_url.'/api/search';
$response = drupal_http_request($url, array(
'headers' => array('Content-Type' => 'application/json', 'Accept' => 'application/json'),
'method' => 'POST',
'data' => json_encode($data),
'max_redirects' => 0,
)
);
print the response to check if its working fine.
CHECK LIST:
- check for any log in by enabling DB logging module call your service.
- check for any syntax error because that file is called only when services is call until then you wont see any error or warning.
- print the response and test the data is passing correctly or not.
- check the client end to check.