Contentful PHP API: how to get just one single entry?

51 views Asked by At

I'm using this code to get all my content in Contentful (they are projects and within each project a gallery of images) for a simple portfolio website.

$client = new \Contentful\Delivery\Client('xxx-xxx-xxx', 'xxx', 'master');
$query = (new Contentful\Delivery\Query())->setContentType('MyPortfolio')->orderBy('-fields.createdOn');
$entries = $client->getEntries($query);

what I do not understand is how to filter and get only one project, given I have its ID (the id is coming from $_GET passed in the url.

This may be super rookie, but can you help me?

1

There are 1 answers

0
The-DC84 On

Try this:

$client->getEntry($assetId);