Skip to content

Commit 107740d

Browse files
reithoradriendupuis
andcommitted
Perso REST: update namespace (#2346)
* ezp → ibexa --------- Co-authored-by: Adrien Dupuis <[email protected]> (cherry picked from commit 6bbfb04)
1 parent 3193140 commit 107740d

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed

docs/personalization/enable_personalization.md

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
description: Configure your project files to enable Personalization and set up items you want to track.
32
---
43

@@ -161,33 +160,41 @@ Place the following code snippet in the `<head>` section of your header template
161160
### Check whether the bundle provides REST data
162161

163162
You can verify the import controller of the bundle by calling the local API.
164-
Use the `Accept` header; you may need to add an `Authorization` header if authentication is required.
163+
As the API uses token based authorization you first need a valid bearer token.
165164

166-
To check whether the `content` endpoint is working as expected, perform the following request:
165+
When you publish a content item a bearer token is created and saved to the `ibexa_token` db table.
167166

168-
```
169-
GET http://<yourdomain>/api/ezp/v2/ibexa_personalization/v1/content/{contentId}
170-
Accept application/vnd.ez.api.Content+json
171-
Authorization Basic xxxxxxxx
172-
```
167+
Additionally a POST request is send to the Personalization Engine, containing the token
168+
and the Rest URL where the Personalization Engine can fetch the changed Content.
169+
170+
The `BEARER_TOKEN` is the newest one in `ibexa_token` table having `type=1` and `identifier=update`. The token has a default lifetime of one day.
173171

174-
Additionally, check whether the `contenttypes` endpoint is working with the following request:
172+
You can use this token to check what is provided to the Personalization Engine:
175173

174+
175+
```bash
176+
curl --location '{PERSONALIZATION_HOST_URI}/api/ibexa/v2/personalization/v1/content/id/{contentId}?lang={comma_separated_languages}' \
177+
--header 'Accept: application/vnd.ibexa.api.Content+json' \
178+
--header 'Authorization: Bearer {BEARER_TOKEN}'
176179
```
177-
GET http://<yourdomain>/api/ezp/v2/ibexa_personalization/v1/contenttypes/38?page=1&page_size=10
178-
Accept application/vnd.ez.api.Content+json
179-
Authorization Basic xxxxxxxx
180+
181+
Additionally, check whether the `contentlist` endpoint is working with the following request:
182+
183+
```bash
184+
curl --location '{PERSONALIZATION_HOST_URI}/api/ibexa/v2/personalization/v1/contentlist/{comma_separated_content_ids}?lang={comma_separated_languages}' \
185+
--header 'Accept: application/vnd.ibexa.api.ContentList+json' \
186+
--header 'Authorization: Bearer {BEARER_TOKEN}'
180187
```
181188

182-
The `content` endpoint returns one item and the `contenttypes` endpoint returns many.
189+
The `content` endpoint returns one item and the `contentlist` endpoint returns many.
183190

184191
``` json
185192
{
186193
"contentList": {
187-
"_media-type": "application/vnd.ez.api.contentList+json",
194+
"_media-type": "application/vnd.ibexa.api.ContentList+json",
188195
"content": [
189196
{
190-
"_media-type": "application/vnd.ez.api.content+json",
197+
"_media-type": "application/vnd.ibexa.api.Content+json",
191198
"contentId": 72,
192199
"contentTypeId": 38,
193200
"identifier": "place",
@@ -197,18 +204,18 @@ The `content` endpoint returns one item and the `contenttypes` endpoint returns
197204
"uri": "/Places-Tastes/Places/Kochin-India",
198205
"categoryPath": "/1/2/95/71/73/",
199206
"mainLocation": {
200-
"_media-type": "application/vnd.ez.api.mainLocation+json",
207+
"_media-type": "application/vnd.ibexa.api.mainLocation+json",
201208
"_href": "/api/ezp/v2/content/locations/1/2/95/71/73/"
202209
},
203210
"locations": {
204-
"_media-type": "application/vnd.ez.api.locations+json",
211+
"_media-type": "application/vnd.ibexa.api.locations+json",
205212
"_href": "/api/ezp/v2/content/objects/72/locations"
206213
},
207214
"name": "Kochin, India",
208-
"intro": "<![CDATA[<section xmlns=\"http://ez.no/namespaces/ezpublish5/xhtml5\"><p>We got the major port city on the south west coast of India.</p></section>\n]]>",
209-
"description": "<![CDATA[<section xmlns=\"http://ez.no/namespaces/ezpublish5/xhtml5\"><p><strong>Kochi </strong>(formerly Cochin) ... </p></section>\n]]>",
215+
"intro": "<![CDATA[<section xmlns=\"http://ibexa.co/namespaces/ezpublish5/xhtml5\"><p>We got the major port city on the south west coast of India.</p></section>\n]]>",
216+
"description": "<![CDATA[<section xmlns=\"http://ibexa.co/namespaces/ezpublish5/xhtml5\"><p><strong>Kochi </strong>(formerly Cochin) ... </p></section>\n]]>",
210217
"image": "/var/site/storage/images/places-tastes/places/kochin-india/282-5-eng-GB/Kochin-India.jpg",
211-
"caption": "<![CDATA[<section xmlns=\"http://ez.no/namespaces/ezpublish5/xhtml5\"><p>Chinese fishing nets ... </p></section>\n]]>",
218+
"caption": "<![CDATA[<section xmlns=\"http://ibexa.co/namespaces/ezpublish5/xhtml5\"><p>Chinese fishing nets ... </p></section>\n]]>",
212219
"location": "kochin, india",
213220
"authors_position": "Senior Editor",
214221
"tags": "India, Kochin",
@@ -228,30 +235,19 @@ To get recommendations you must first export the item information to the Persona
228235
After you [define item types to be tracked and recommended](#set-up-item-type-tracking),
229236
start the full export.
230237

231-
You do it with the `ibexa:personalization:run-export` command.
232-
233-
If your installation hosts only one SiteAccess, run the following command to export your data:
234-
235-
``` bash
236-
php bin/console ibexa:personalization:run-export
237-
--item-type-identifier-list=<item_type>,<item_type>
238-
-—languages=<language>,<language>
239-
```
240-
241-
If your installation hosts multiple SiteAccesses with different customer IDs,
242-
you must run the export separately for each of the `<site_access_name>`/`<customer_id>` pairs.
238+
You need to run the `ibexa:personalization:run-export command per SiteAccesses that you want to use together with Personalization. You need different customer IDs for different SiteAccesses.
243239

244240
``` bash
245241
php bin/console ibexa:personalization:run-export
246242
--item-type-identifier-list=<item_type>,<item_type>
247243
--siteaccess=<site_access_name>
248244
--customer-id=<customer_id>
249245
--license-key=<license_key>
250-
-languages=<language>,<language>
246+
--languages=<language>,<language>
251247
```
252248

253249
The bundle exporter collects all content related to the `<site_access_name>`/`<customer_id>`
254-
pair and stores it in files.
250+
pair and stores it in files to the folder `public/var/export/yyyy/mm/dd/hh/mm` of your project.
255251
After finishing, the system sends a POST request to the endpoint and informs the
256252
Personalization server to fetch new content.
257253
An internal workflow is then triggered, so that the generated files are downloaded
@@ -310,13 +306,13 @@ The username is the customer ID and the password is the license key.
310306
<attribute value="/1/2/95/71/74/" key="categoryPath" type="TEXT"/>
311307
<attribute value="Michael Wang" key="author" type="NOMINAL"/>
312308
<attribute value="0" key="rating" type="TEXT"/>
313-
<attribute value="&lt;![CDATA[&lt;section xmlns=&quot;http://ez.no/namespaces/ezpublish5/xhtml5&quot;&gt;&lt;p&gt;Outstanding beaches of Dominican Republic, Samana is one of them.&lt;/p&gt;&lt;p&gt;&lt;em&gt;Photograph by Brian Henry - Anchorage north shore Samana, Dominican Republic&lt;/em&gt;&lt;/p&gt;&lt;/section&gt;&#xA;]]&gt;" key="caption" type="TEXT"/>
309+
<attribute value="&lt;![CDATA[&lt;section xmlns=&quot;http://ibexa.co/namespaces/ezpublish5/xhtml5&quot;&gt;&lt;p&gt;Outstanding beaches of Dominican Republic, Samana is one of them.&lt;/p&gt;&lt;p&gt;&lt;em&gt;Photograph by Brian Henry - Anchorage north shore Samana, Dominican Republic&lt;/em&gt;&lt;/p&gt;&lt;/section&gt;&#xA;]]&gt;" key="caption" type="TEXT"/>
314310
<attribute value="/Places-Tastes/Places/Santo-Domingo-Dominican-Republic" key="uri" type="TEXT"/>
315311
<attribute value="38" key="contentTypeId" type="TEXT"/>
316312
<attribute value="Dominican Republic, Santo Domingo" key="tags" type="TEXT"/>
317-
<attribute value="&lt;![CDATA[&lt;section xmlns=&quot;http://ez.no/namespaces/ezpublish5/xhtml5&quot;&gt;&lt;p&gt;Santo Domingo meaning &quot;Saint Dominic&quot;, officially Santo Domingo de Guzm&amp;aacute;n, is the capital and largest city in the ... &lt;/p&gt;&lt;/section&gt;&#xA;]]&gt;" key="description" type="TEXT"/>
313+
<attribute value="&lt;![CDATA[&lt;section xmlns=&quot;http://ibexa.co/namespaces/ezpublish5/xhtml5&quot;&gt;&lt;p&gt;Santo Domingo meaning &quot;Saint Dominic&quot;, officially Santo Domingo de Guzm&amp;aacute;n, is the capital and largest city in the ... &lt;/p&gt;&lt;/section&gt;&#xA;]]&gt;" key="description" type="TEXT"/>
318314
<attribute value="73" key="contentId" type="TEXT"/>
319-
<attribute value="&lt;![CDATA[&lt;section xmlns=&quot;http://ez.no/namespaces/ezpublish5/xhtml5&quot;&gt;&lt;p&gt;The oldest European inhabited settlement in the Americas.&lt;/p&gt;&lt;/section&gt;&#xA;]]&gt;" key="intro" type="TEXT"/>
315+
<attribute value="&lt;![CDATA[&lt;section xmlns=&quot;http://ibexa.co/namespaces/ezpublish5/xhtml5&quot;&gt;&lt;p&gt;The oldest European inhabited settlement in the Americas.&lt;/p&gt;&lt;/section&gt;&#xA;]]&gt;" key="intro" type="TEXT"/>
320316
<attribute value="1442500260" key="publication_date" type="TEXT"/>
321317
<attribute value="Santo Domingo, Dominican Republic" key="name" type="TEXT"/>
322318
<attribute value="Santo Domingo, Dominican Republic" key="location" type="TEXT"/>
@@ -359,7 +355,7 @@ and it eventually fetches the affected content and updates it internally.
359355
To display recommendations on your site, you must include the asset in the template using the following code:
360356

361357
``` html+twig
362-
{{ encore_entry_script_tags('ezrecommendation-client-js', null, 'ezplatform') }}
358+
{{ encore_entry_script_tags('ibexa-personalization-client-js', null, 'ibexa') }}
363359
```
364360

365361
This file is responsible for sending notifications to the [Recommendation API](recommendation_api.md) after the user clicks a tracking element.

0 commit comments

Comments
 (0)