Forum
Import API & Cronjob
Awesome, with https://perchrunway.com/blog/2017-02-10-importing-content-into-collections it will be a breeze to pull external content into perch.
Not only once, but also on a regular basis. I do this very often in another CMS, pulling in members lists, courses, etc from APIs or as exported CSVs from Dropboxes. All you need is a cronjob and $Importer->empty_collection();
, so you can import the whole collection again, say every hour.
What I'm not sure is the duration of the gap between empty_collection()
and add_item()
. In theory, there will be a moment where the collection will be empty. For a small dataset it probably won't matter.
What do you think about that time/data gap?
PS: Here's a next step for later :-)
$Importer->update_item([
'match_field' => 'source_id',
'source_id' => '12345',
'title' => 'Breaking news!',
'body' => 'Some **exciting news** has _just_ broken...',
'slug' => 'breaking-news',
'date' => '2012-04-28 12:23:09',
'category' => ['articles/news', 'articles/flippin-exciting'],
]);
$Importer->delete_orphaned_items([
'match_field' => 'source_id',
]);
I don't understand your question. What problem are you experiencing?
Hi Drew - not a problem. Just pondering:
$Importer->empty_collection();
frequently and import fresh data easilyI wondered if you find that a good idea or not
That would be fine.
cool !