How to use custom field in webhook url

Discussion in 'Common issues' started by 007, Aug 7, 2018.

  1. 007

    007 Member

    Joined:
    Sep 22, 2017
    Messages:
    67
    Likes Received:
    11
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    Hi all,
    How do I use a custom field in a webhook url, like this?

    Code:
    http://myurl.com/?example-field=[EXAMPLE_FIELD]
    I've tested the above url, and mailwizz sends "[EXAMPLE_FIELD]" instead of the value of that field for that user. I'm testing this for the unsubscribe confirmation list page.
     
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    9,314
    Likes Received:
    2,208
    @007 - Looking through the code it seems we don't parse the tags in the request url, but that should be easily done.
    Open /apps/common/extensions/list-form-custom-webhooks/ListFormCustomWebhooksExt.php
    and at line 273 you have:
    PHP:
    try {
        foreach (
    $webhooks as $webhook) {
            if (
    $webhook->request_type == ListFormCustomWebhook::REQUEST_TYPE_POST) {
                
    AppInitHelper::simpleCurlPost($webhook->request_url$data5);
            } elseif (
    $webhook->request_type == ListFormCustomWebhook::REQUEST_TYPE_GET) {
                
    $url  $webhook->request_url;
                
    $url .= (strpos($url'?') === false) ? '?' '&';
                
    $url .= http_build_query($data'''&');
                
    AppInitHelper::simpleCurlGet($url5);
            }
        }
    } catch (
    Exception $e) {}
    make it:
    PHP:
    try {
        foreach (
    $webhooks as $webhook) {
         
    $campaign = new Campaign();
         
    $campaign->customer_id $list->customer_id;
         
    $campaign->list_id     $list->list_id;
       
       
            list(,,
    $url) = CampaignHelper::parseContent($webhook->request_url$campaign$subscriber);
            if (
    $webhook->request_type == ListFormCustomWebhook::REQUEST_TYPE_POST) {
                
    AppInitHelper::simpleCurlPost($url$data5);
            } elseif (
    $webhook->request_type == ListFormCustomWebhook::REQUEST_TYPE_GET) {
                
    $url .= (strpos($url'?') === false) ? '?' '&';
                
    $url .= http_build_query($data'''&');
                
    AppInitHelper::simpleCurlGet($url5);
            }
        }
    } catch (
    Exception $e) {}
    That should do it.
     
  3. 007

    007 Member

    Joined:
    Sep 22, 2017
    Messages:
    67
    Likes Received:
    11
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    Thanks @twisted1919! I see this isn't included in the v1.6.1 release. Will you be adding this to further releases?
     
  4. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    9,314
    Likes Received:
    2,208
    @007 - Did it work like you wanted it ?
    If it did, then yes, will add it.
     
  5. 007

    007 Member

    Joined:
    Sep 22, 2017
    Messages:
    67
    Likes Received:
    11
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    @twisted1919
    It's working perfectly as I'd like, thank you! Yes, it'd be great to see it in the next release.
     
    twisted1919 likes this.

Share This Page