I'm building an app that allows the app to hit an ACT url which then triggers a module method to create a new entry using the ExpressionEngine API. However, as there is no user logged in / loggin in, it is not allowed to submit an entry to a channel.
What is the best way to do this. Bypass the EE api and submit the entry manually, or log a user in progamatically..but then how would that work with sessions etc etc?
If the answer is to "log a user in" it would be great to see a code sample if possible.
Thanks!
As you mention, there are 2 ways to add a new entry:
The main differences are that entries added using the API will:
Adding the entry manually is reasonably easy for simple channels, but gets more complicated if you are using 3rd party fieldtypes that use additional tables.
To log a member in you should just need to:
// Get the member's id (the member must have permissions to post entries)
$member_id = 1;
// Create session
$this->EE->session->create_new_session($member_id);
use the channel entries api to add the entry, and then:
// Log user back out
$this->EE->session->destroy();
when you have finished.