<p>FeedMe shows you what the import trigger endpoint that you can use with curl in the feed configuration.</p>

CC BY-SA 4.0
2019-11-06T22:10:20.963Z
That's what I'm doing right now but my controller action seems to handle the import synchronous and waits for it to end.
Kobe Aerts
CC BY-SA 4.0
2019-11-05T20:39:45.387Z
2019-11-05T20:39:45.387Z
Jim Wyse
<p>One potential way is to trigger curl from your plugin with <code>exec</code>:</p>

<pre><code>// Set the feed me URL
$url =  'http://your.domain/actions/feed-me/feeds/run-task?direct=1&amp;feedId=1&amp;passkey=FwafY5kg3c'

// Build the curl command with the url
$cmd = 'curl --silent --compressed "'.$url.'"';

// Execute the command in the background
exec($cmd . " &gt; /dev/null &amp;");
</code></pre>

<p>That should then run the task using another process. </p>

<p>You will likely need to enable <code>exec()</code> function on your environment. </p>

<p>Even better if you use a daemon to process your queue with a <code>nice</code> command (if not <a href="https://nystudio107.com/blog/robust-queue-job-handling-in-craft-cms" rel="nofollow noreferrer">have a look here</a>) it will run as a low priority task and slow your front-end down less.</p>

CC BY-SA 4.0
2019-11-07T13:39:39.123Z
2019-11-11T15:09:05.653Z
2019-11-11T15:09:05.653Z
dmatthams
<p>I'm importing Real Estate properties every 30 minutes into my website.
I have a controller action that triggers this but the import is extremely slow and blocks the entire site.</p>

<p>Right now I'm triggering the imports with this code:</p>

<pre><code>$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_exec($ch);
curl_close($ch);
</code></pre>

<p>Where the url is the cron url of the feed.</p>

CC BY-SA 4.0
2019-11-06T11:35:52.557Z
What's the reason you don't point the cron job directly at the FeedMe url?
dmatthams
CC BY-SA 4.0
2019-11-06T22:08:44.030Z
Because I first need to generate the json file before I can import it. It's a dynamic thing.
Kobe Aerts
CC BY-SA 4.0
2019-11-11T15:10:25.377Z
Hey, I've had to do this today so have updated my answer with the solution I have: https://craftcms.stackexchange.com/a/32955/526
dmatthams
<plugin-development><plugin-feedme><modules>
Trigger FeedMe import from plugin
# Trigger FeedMe import from plugin

(Asked by: username_0 on 2019-11-05)

I'm importing Real Estate properties every 30 minutes into my website.
I have a controller action that triggers this but the import is extremely slow and blocks the entire site.
Right now I'm triggering the imports with this code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_exec($ch);
curl_close($ch);

Where the url is the cron url of the feed.

**Tags:** plugin-development, plugin-feedme, modules

> **Comments:**
> **username_1**: What's the reason you don't point the cron job directly at the FeedMe url?  
> **username_0**: Because I first need to generate the json file before I can import it. It's a dynamic thing.  
> **username_1**: Hey, I've had to do this today so have updated my answer with the solution I have: https://craftcms.stackexchange.com/a/32955/526  

---

## 2 answers

### Answer by username_2 on 2019-11-05. Score: 1

FeedMe shows you what the import trigger endpoint that you can use with curl in the feed configuration.

> **Comments:**
> **username_0**: That's what I'm doing right now but my controller action seems to handle the import synchronous and waits for it to end.  

---

### Answer by username_1 on 2019-11-07. Score: 1

One potential way is to trigger curl from your plugin with exec:
// Set the feed me URL
$url =  'http://your.domain/actions/feed-me/feeds/run-task?direct=1&feedId=1&passkey=FwafY5kg3c'

// Build the curl command with the url
$cmd = 'curl --silent --compressed "'.$url.'"';

// Execute the command in the background
exec($cmd . " > /dev/null &");

That should then run the task using another process. 
You will likely need to enable exec() function on your environment. 
Even better if you use a daemon to process your queue with a nice command (if not have a look here) it will run as a low priority task and slow your front-end down less.


---

