Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-05-19 05:16:07

astick360
Member
Registered: 2022-05-05
Posts: 23

Integrate with the use of the API with an external system

I need to integrate TXP with an external system. The rule is that the article will be prepared in the external system. Because he must undergo a decision cycle where it will edit and accept several people. These people are users of this external system. After undergoing the trial, I would want to send information through the API to TXP to publish the accepted content as an article in a specific section. The data that I want to deliver to TXP by API is: title, content, teaser, publication date and image. Perhaps some other fields. A request for the possibility of how it can be done and what to use? Of course, the rest of the page outside this one section is to be edited normally in TXP, it is only one section where the decision process is complicated. What are the possibilities on the TXP side?

Offline

#2 2024-05-19 06:58:56

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,734
Website

Re: Integrate with the use of the API with an external system

I guess there are a few approaches:

  • If the articles do not actually need to be stored a second time in Textpattern, you could output the data as an xml feed from your external system, and then just reference and render that feed at the desired place in your Textpattern site. smd_xml (GitHub) and etc_query (forum thread) and possibly also ais_feed can help there. smd_xml and ais_feed traverse xml, etc_query can traverse json and well-formed html. This is certainly the easier option.
  • If you do need to actually save that data to textpattern, there is etc_post (forum thread) and smd_query (GitHub), though with the latter, you’ll need to construct your database insert queries yourself. Note that it gets more complicated if you need to import images/files as well (as opposed to just the link to them externally). As ever, sanitise incoming data before submitting it to the database.

It would be great if you could document what you come up with.

EDIT: there’s also etc_import which you could use to bring in an image in conjunction with etc_post. See this post for example.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB