web-services - 在 drupal 7 中使用 View 服务选择语言

标签 web-services rest drupal drupal-7

我将 View 服务模块与休息服务一起使用。 View 使用“当前用户的语言”显示内容,但当我获取内容时,总是以默认语言返回。

例如:

http://example.com/api1_rest/views/content_view?id_display=page&limit=10&offset=0

返回

[  
   {  
      "vid":"300",
      "uid":"4",
      "title":"node title",
      "log":"",
      "status":"1",
      "comment":"0",
      "promote":"0",
      "sticky":"0",
      "nid":"2488",
      "type":"news",
      "language":"en",
      "revision_timestamp":"1422900078",
      "revision_uid":"1",
      "body":{  
         "en":[  
            {  
               "value":"content body here",
               "summary":"",
               "format":"4"
            }
         ]
      },
}
]

我需要在休息申请中选择语言。

最佳答案

来自 Services Views module page :

You can create exposed filters and pass them to your resource. For example if we created exposed filter "tags" call will be: http://example.com//?tags=7

因此,您可以在 View 中为语言创建一个公开的过滤器,而不仅仅是通过将 &lang=en 添加到 url 来过滤结果:

http://example.com/api1_rest/views/content_view?id_display=page&limit=10&offset=0&lang=en

关于web-services - 在 drupal 7 中使用 View 服务选择语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29507850/

相关文章:

c# - HTTP Get 请求中的 Unicode 字符

javascript - 为什么 onload 事件没有按预期绑定(bind) `this` 变量?

php - PayPal REST SDK 未在 execute() 上返回正确状态

c# - EPERM : Operation not permitted - NPM Angular 7 on IIS with backend . 网络核心 2.1

json - RestController 中的 Spring SCALA 返回列表

德鲁帕尔 6 : Installation Profile

javascript - drupal_add_js 在 hook_user_login 中不起作用

apache - 从 https 重写为 http

asp.net - 如何使用 ASP.NET 调用 Web 服务(.wsdl)

api - 播客搜索 API