This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 4

Dynamic Website url for webhook (send data to website), incl. solution


  1. Tiron
    Member

    Hi,

    we send data to a mailing-app and they need to have the emailadress in the website-url, like this:
    https://api.maileon.com/1.0/contacts/max.mustermann%40xqueue.com?permission=1

    It is currently not possible to do this like this:
    https://api.maileon.com/1.0/contacts/{element_3}?permission=1
    where {element_3} is the emailfield in the form.

    I added that functionality in helper-functions.php around line 320, just before

    //send the data to the URL
    $webhook_url_info = parse_url($webhook_url);

    i added:

    $template_values = array_map('urlencode', $template_values);
    
    //replace stuff also in the url
    $webhook_url = str_replace($template_variables, $template_values, $webhook_url);

    This fixes it, maybe you can add it to an future update.
    It would also be great to have the possibility to only send the form-data over api if there are specific conditions which are met.

    Greetings
    Tiron

    Posted 10 years ago #
  2. Tiron
    Member

    Hi again,

    i added further code, because get parameters i added to the url in a post request didnt appear and that was a problem.

    Example as above in my first post: https://api.maileon.com/1.0/contacts/max.mustermann%40xqueue.com?permission=1

    the permission=1 is missing in the request.

    So i changed the code around line 320 again to the following:

    if(trim($webhook_url_info['query']) != '')
    	$query = '?'.$webhook_url_info['query'];
    else
    	$query = '';
    
    $path = $webhook_url_info['path'].$query;
    
    if($webhook_method == 'post'){
    	$webhook_client->post($path, $webhook_data, $webhook_headers);
    }elseif ($webhook_method == 'get') {
    	$webhook_client->get($path, $webhook_data, $webhook_headers);
    }elseif ($webhook_method == 'put') {
    	echo "running PUT";
    	$webhook_client->put($path, $webhook_data, $webhook_headers);
    }
    Posted 10 years ago #

RSS feed for this topic

Reply