2015-11-23 5 views

Répondre

1

Je peux obtenir des valeurs via l'API REST.

/** 
* Implements hook_menu(). 
*/ 
function sample_menu() { 
    $items['api/sample'] = array(
     'title' => 'Sample REST API', 
     'page callback' => 'sample_api', 
     'access callback' => true 
    ) 
} 

/** 
* callback function for /api/sample 
*/ 
function sample_api() { 
    $entityBody = file_get_contents('php://input'); // if you want to get post data 
    drupal_add_http_header('Content-Type', 'application/json'); 

    // set values from Fields and so on 

    drupal_json_output(array("output" => 'this is rest api sample module output.', 'id' => 12345)); 
    drupal_exit(); 
} 
+0

@Banng Si vous résolvez ce problème, je veux que vous fermiez ce problème. – ima0123