Contentful logo

Contentful Community

Content Preview Api

Hi,
I would like to set up a preview that shows up on my staging site, but not on the production site.

Could someone tell me how how to access the Content Preview API using the php sdk?

I tried replacing $client = new \Contentful\Delivery\Client(…) with $client = new \Contentful\Preview\Client(), but no luck.

Thanks,

Oliver

check out Using this SDK with the Preview API from the README of the Contentful.PHP GitHub repo. Essentially you do the following:

$options = \Contentful\Delivery\ClientOptions::create()
    ->usingPreviewApi();
$client = new \Contentful\Delivery\Client($accessToken, $spaceId, $environmentId, $options);