Forum

Thread tagged as: Question, Api

Best place to register a scheduled task

Hi all,

i am sure i am being incredibly dim here but for some reason i can't figure it out this morning. I have created a website in Runway, all working great but the last task is to integrate Instagram in such a way that it pulls the posts into a feed of posts which is mixed in with other posts that they create from within the perch admin.

My thinking has always been to create a scheduled task that would run and grab the Instagram posts and add them to the perch database programatically, which looking at the perch scheduled tasks setup is still the way to go but i can't seem to understand the process of setting up the task or the best place to register it. Is it just the case of registering a init function that does the rest of the work, so registering a function called 'import_instagram_posts' for example

PerchScheduledTasks::register_task('perch_instagram', 'post_instagram_post', 1, 'import_instagram_posts');

Is there a preferred place to do this as well? the examples i have found all seem to sit in a dedicated app, and at this stage as this requirement is quite specific seems like overkill to create one, but i am sure i am just being dim as i said and missing the obvious.

Any advice would be greatly appreciated.

Thanks,

Rob

Roberto Modica

Roberto Modica 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

A 'dedicated app' is just a folder with some files in. Create a folder for your app, add a scheduled_tasks.php file to it and register your tasks in there.

btw, you shouldn't use perch_instagram as the name - perch_ is our developer prefix, you should use your own.

Hi Drew,

My crappy are examples are crappy :)

Thanks for the info, like i said i was sure i was missing the obvious, and have been burnt before when having to create an app meant a ton of boilerplate for the most simple of things, great to see that is not the case here.

Thanks!