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.

  • 1
    Check out this question which is very similar (only dealing with users instead of entries, but same principles apply). See if that helps. Feb 16 '15 at 21:03

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;

        '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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.