【问题标题】:Contentful Query Content Types in PHPPHP 中的内容查询内容类型
【发布时间】:2019-03-27 18:58:25
【问题描述】:

我对 Contentful 非常陌生,并试图从我的 Contentful 数据库中获取一种特定内容类型“公司”的所有项目,但我收到错误消息:

`400 Bad Request` response: { "sys": { "type": "Error", "id":
"InvalidQuery" }, "message": "The query you sent was invalid. Probably
a (truncated...) in

我的代码是:

$client = new Client($accessToken, $spaceID);
$query = new \Contentful\Delivery\Query();
$query->setContentType('hosting_companies');
$entries = $client->getEntries($query);

有人知道我可能会错过什么吗?

非常感谢!

【问题讨论】:

  • 您可以通过捕获GuzzleHttp\Exception\ClientException 并在其上调用getResponse()->getBody()->getContents() 来获得整个响应(未截断)。也许它会给你一个提示。

标签: php contentful


【解决方案1】:

我不是 100% 精通 php sdk,但您查询内容类型 id 'hosting' 并在描述中说“companies”?

查看 Contentful 文档中的这个示例,整体结构看起来还不错。

https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/content-type/query-entries/console/php

【讨论】:

    【解决方案2】:

    我找到了问题的根源:在 Contentful 我们将内容类型称为hosting_companies。 Contentful 把它变成了hostingCompanies (CamelCase),我没有意识到这一点。一旦我更改了查询,它就起作用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-03
      • 2013-03-26
      • 1970-01-01
      • 2013-09-01
      • 2017-07-22
      • 2013-07-05
      • 1970-01-01
      相关资源
      最近更新 更多