Forum Discussion
emily_wri
2 months agoSupporter
WordPress API to Catalogs
Hi all, I'm trying to automate the process of getting our blog posts (on wordpress) updated to a catalog. Ideally, this would automatically create a new catalog item when a new blog was created and...
phil_l
1 month agoSupporter
You could also do this purely in Braze using connected content and webhooks. e.g.
PUT https://rest.iad-XX.braze.com/catalogs/events/items
In your webhook body, get today's posts from Wordpress
{% assign today_start = now | date: "%Y-%m-%dT00:00:00" %}
{% assign today_end = now | date: "%Y-%m-%dT23:59:59" %}
{% connected_content
https://your-site.com/wp-json/wp/v2/posts?status=publish&after={{ today_start | url_encode }}&before={{ today_end | url_encode }}&per_page=20&orderby=date&order=desc&_fields=id,title,link,date
:method get
:retry 1
:save posts
%}And then loop through the items if there are any e.g.
{% if posts and posts.size > 0 %}
{
"items": [
{% for p in posts %}
{
"id": "{{p.id}}",
"title": "{{p.title}}",
"link": "{{p.link}}",
}{% if forloop.last %}{% else %},{% endif %}
{% endfor %}
]
}
{% endif %}Depending on how often you're updating the blog, schedule it to run a few times a day
Related Content
- 1 year ago
- 1 year ago
- 10 months ago