<p>You would need to set this up using a plugin. The plugin would, at a minimum, contain a <a href="http://buildwithcraft.com/docs/plugins/controllers#how-controller-actions-fit-into-routing" rel="nofollow">controller</a>, with an 'action' method designed to handle the url request and generate an entry; using 'post' or 'get' to pass parameters to the controller action.</p>

<pre><code>public function actionAddEntry()
{
    // retrieve parameters
    $title             = craft()-&gt;request-&gt;getParam('title');
    $customField1      = craft()-&gt;request-&gt;getParam('customField1');
    $customField2      = craft()-&gt;request-&gt;getParam('customField2');

    // create a new entry model and set content attributes
    $entry = new entryModel();
    $entry-&gt;sectionId  = 2; 
    $entry-&gt;typeId     = 2; 
    $entry-&gt;authorId   = 1; 
    $entry-&gt;enabled    = true;

    $entry-&gt;getContent()-&gt;setAttributes(array(     
        'title'        =&gt; $title,     
        'customField1' =&gt; $customField1,
        'customField2' =&gt; $customField2,
    )); 

    // save entry
    $success = craft()-&gt;entries-&gt;saveEntry($entry);

    // handle success or failure
    if ($success) {
        // log result or send yourself an email or whatever
    } else {
        // log error
    }
};
</code></pre>

<p>By default however, controller actions are only accessible to logged-in users. If you want to allow anonymous access you would need to specifically allow it using the <a href="http://buildwithcraft.com/docs/plugins/controllers#allowing-anonymous-access-to-actions" rel="nofollow">$allowAnonymous property</a>. This definitely introduces some security issues, so proceed with caution. Ideally you would want to set up some kind of authentication, or only accept requests from known hosts.</p>

CC BY-SA 3.0
2015-02-16T22:07:34.037Z
2015-02-16T22:07:34.037Z
Douglas McDonald
<p>I want to create an entry in an existing channel via a webhook from zoho crm. It's pretty straightforward. Like many apps, Zoho's webhook allows you to specify destination url, the method (get or post), and what parameters to pass.</p>

<p>Do I need to create a plugin to receive this form post or is there another way? </p>

<p>I'm a plugin newbie, so any links on where to start would be helpful.</p>

CC BY-SA 3.0
2015-02-16T21:03:49.957Z
Check out [this question](http://craftcms.stackexchange.com/questions/7172/automatically-create-users-from-http-header) which is very similar (only dealing with users instead of entries, but same principles apply). See if that helps.
Douglas McDonald
<entry><post>
How to create entry from external app webhook?
# How to create entry from external app webhook?

(Asked by: username_0 on 2015-02-16)

I want to create an entry in an existing channel via a webhook from zoho crm. It's pretty straightforward. Like many apps, Zoho's webhook allows you to specify destination url, the method (get or post), and what parameters to pass.

Do I need to create a plugin to receive this form post or is there another way?

I'm a plugin newbie, so any links on where to start would be helpful.

**Tags:** entry, post
> **Comments:**
> **username_1**: Check out [this question](http://craftcms.stackexchange.com/questions/7172/automatically-create-users-from-http-header) which is very similar (only dealing with users instead of entries, but same principles apply). See if that helps.  

---

## 1 answers

### Answer by username_1 on 2015-02-16. Score: 2 | Accepted answer

You would need to set this up using a plugin. The plugin would, at a minimum, contain a controller, with an 'action' method designed to handle the url request and generate an entry; using 'post' or 'get' to pass parameters to the controller action.
public function actionAddEntry()
{
    // retrieve parameters
    $title             = craft()->request->getParam('title');
    $customField1      = craft()->request->getParam('customField1');
    $customField2      = craft()->request->getParam('customField2');

    // create a new entry model and set content attributes
    $entry = new entryModel();
    $entry->sectionId  = 2; 
    $entry->typeId     = 2; 
    $entry->authorId   = 1; 
    $entry->enabled    = true;

    $entry->getContent()->setAttributes(array(     
        'title'        => $title,     
        'customField1' => $customField1,
        'customField2' => $customField2,
    )); 

    // save entry
    $success = craft()->entries->saveEntry($entry);

    // handle success or failure
    if ($success) {
        // log result or send yourself an email or whatever
    } else {
        // log error
    }
};

By default however, controller actions are only accessible to logged-in users. If you want to allow anonymous access you would need to specifically allow it using the $allowAnonymous property. This definitely introduces some security issues, so proceed with caution. Ideally you would want to set up some kind of authentication, or only accept requests from known hosts.


---

