2017-05-31 71 views
0

我想在drupal服務API中使用查詢字符串結構。它不適合我。 我也搜索了大部分解決方案,但都失敗了。 這裏爲m的Drupal代碼:查詢drupal服務自定義資源中的字符串

function rapid_services_resources() { 
    $resources = array(
    'get_data' => array(
     'operations' => array(
     'retrieve' => array(
      'help' => t('Gets user email of uid passed.'), 
      'callback' => 'my_module_get_user_email', 
      'args' => array(
       array(
       'name' => 'nid', 
       'type' => 'int', 
       'description' => 'The display ID of the view to get.', 
       'source' => array('param' => 'nid'), 
       'optional' => TRUE, 
       'default value' => 'default', 
      ), 
     ), 
      'access arguments' => '_blog_access_provide_access', 
      'access callback' => '_blog_access_provide_access', 
      //~ 'access arguments append' => FALSE, 
     ), 
    ), 
    ), 
); 
    return $resources; 
} 

function _blog_access_provide_access() { 
    return TRUE; 
} 

function my_module_get_user_email($nid){ 
    var_dump($args);die; 
} 

我想要的網址是這樣。:

http://localhost/drupaltest/rapidapi/get_data/?nid=111 

請讓我知道我做錯了。 在此先感謝。

回答

0

嗨這裏是參考,這將是

http://pingv.com/blog/an-introduction-drupal-7-restful-services

https://www.drupal.org/node/783460

而且我不知道的查詢字符串是有用的,但是對於檢索操作,你可以將其設置爲部分URL 例如:

http://localhost/drupaltest/rapidapi/get_data/<nid should be here> 
http://localhost/drupaltest/rapidapi/get_data/111 

而且使用源路徑作爲源

'source' => array('path' => '0'), 

我認爲源param只適用於一個index操作,而不是檢索

相關問題