- 先安装一个RESTUI模块
- 启用配置好之后可以访问GET接口,例如:http://cto.eguidedog.net/node/241?_format=json
-
POST接口,例如:curl -H "Content-Type: application/json" -X POST -d '{"type":[{"target_id":"braille_printing_application"}],"title":[{"value":"test2"}],"field_address":[{"value":"addr2"}],"field_name":[{"value":"name2"}],"field_phone":[{"value":"phone2"}],"field_zipcode":[{"value":"zipcode2"}]}' http://cto.eguidedog.net/entity/node
- 更多信息参考:https://www.drupal.org/docs/8/core/modules/rest/javascript-and-drupal-8-restful-web-services
- 关于上传文件,可以参考:https://www.drupal.org/node/1927648 ,https://www.drupal.org/node/2748013 ,http://drupal.stackexchange.com/questions/118106/how-to-send-files-to-drupal-8-via-rest。更容易的方法是通过PHP上传,然后引用URL。PHP上传脚本很简单:
<?php
$uploadfile = 'images/' . basename($_FILES['file']['name']) . '.jpg';
move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile);
echo 'http://eguidedog.net/GodErlang/images/' . $uploadfile . '.jpg';
?>
评论