POST data - unable to grab values with square brackets using %globals_post_% keyword

Hi,

 

Any help / advice appreciated.

 

I have webhook post data coming in to a Matrix page.

I have a trigger running on POST event - sending an email which I'm trying to populate with the POST data from the webhook.

All works fine until I get to some POST data that is using square brackets (It's serialised data - converted from an array hence the brackets)

As it's webhooks I am unable to make any changes to way the post data is coming in.

 

Anyway - onto examples.

 

A straightforward POST pair like this:

 

type:profile

 

Works fine. I can use: %globals_post_type% - and pull this data without issue.

 

But a pair like this:

 

data[id]:a123b456

 

And I can't for the life of me get the data using the keyword.

The following did not work:

 

%globals_post_data[id]%

%globals_post_data\[id\]%

 

Using requestbin I can see the raw data is coming through urlencoded like this:

 

&data%5Bid%5D=a123b456

 

But again - the % signs are making it impossible to grab this using the keywords

 

%globals_post_data%5Bid%5D%

 

Substituting html codes for the square brackets doesn't work either:

 

%globals_post_data[id]%

 

Any advice or help greatly appreciated.

 

Karl

 

 

 

 

Hi,U

Unfortunately Matrix currently isn't able to do that in globals keywords replacement. So a regular post variable would work just fine but not the  some_variable[] format one.

I'd suggest you lodge a feature request on bug tracker as adding this feature might be helpful to other users too.

 

Ash

Thanks for replying (even though it's not good news I can stop trying to make it work now).

 

Have posted bug #6146

 

Do you know if there are plans to implement any functionality to handle external webhooks?

 

Karl

Hi Karl,

There are a few assets that can be used to listen to webhooks. I'd say something like REST resource might be helpful to you depending what kind of implementation you have going on.

But as far as I know I don't think there is any particular development coming up.

 

When you said you have a trigger firing on POST data, how is this configured? May be try adding more information on here to see if anyone, who has worked on similar sort of implementation, has any useful tips and tricks for you.

 

Ash

Hi Ash,

I was hoping for a very simple solution to keeping 2 user databases in synch.

 

I can synch the Matrix database with the 3rd party using a trigger and matrix REST action and straightforward query string (as their API accepts http post with serialized values).

 

I was hoping to set a similar simple system up for data coming into Matrix - with their webhook post hitting a standard page - then use either:

 

2 triggers - one to Broadcast an event to the Matrix user - the second to fire on the broadcast event and change the user details

1 trigger - using either SOAP or REST trigger action to make the changes on the user account.

 

I'm scuppered in either of these options as Matrix is unable to pull the post values from the webhook for the reasons above.

 

The only option I can see involves me learning to code php  :unsure: (which isn't really an option at all) - and to install one of the php API wrappers available from the third party.

The other option is to forget the webhooks and push ahead with a more complex integration and somehow get Matrix to regularly poll the other api for changes and then somehow apply these changes within Matrix. However this seems a long way to go around when the system already exists to push data to Matrix as events occur.

 

What I really need is the ability to grab the post values from the webhook and use them in a trigger.

 

The webhook data looks a bit like this:

 

 

data[merges][GROUPINGS][2][id]    133
data[merges][GROUPINGS][2][name]    PMLiVE news alerts
data[merges][INTERESTS]    
data[merges][JOBTITLE]    Creative Director
data[merges][LNAME]    Equi
data[merges][TEL]    2121212121
 
If anyone out there has done anything similar I would be interested to know how you did it!
 
Thanks
 
Karl

What sort of webhook are you using for this?

Hi Nic,

 

Thanks for your interest. The webhook is coming from Mailchimp. (http://apidocs.mailchimp.com/webhooks/)

 

It's an http POST request. "The POST request sends key/value pairs, just like a normal HTML Form Submission"

 

Raw code looks like this in Requestbin.

 

 

type=profile&fired_at=2013-02-07+15%3A31%3A14&data%5Bid%5D=123456789&data%5Bemail%5D=karl_2%40karlequi.co.uk&data%5Bemail_type%5D=html&data%5Bip_opt%5D=xxxxxxxxxxx&data%5Bip_signup%5D=xxxxxxxxxxx&data%5Bweb_id%5D=xxxxxxxxxxx&data%5Bmerges%5D%5BEMAIL%5D=karl_2%40karlequi.co.uk&data%5Bmerges%5D%5BFNAME%5D=Karl_3DD&data%5Bmerges%5D%5BLNAME%5D=Equi&data%5Bmerges%5D%5BJOBTITLE%5D=Creative+Director&data%5Bmerges%5D%5BCOMPANY%5D=123456dedddeddede&data%5Bmerges%5D%5BGEO%5D=Europe&data%5Bmerges%5D%5BADD1%5D=Address+1&data%5Bmerges%5D%5BADD2%5D=Address+2&data%5Bmerges%5D%5BADD3%5D=Address+3&data%5Bmerges%5D%5BCITY%5D=City&data%5Bmerges%5D%5BCOUNTY%5D=County&data%5Bmerges%5D%5BZIP%5D=Postcode&data%5Bmerges%5D%5BCOUNTRY%5D=Fiji&data%5Bmerges%5D%5BTEL%5D=2121212121&data%5Bmerges%5D%5BASSETID%5D=xxxxxxxxxxx&data%5Bmerges%5D%5BINTERESTS%5D=&data%5Bmerges%5D%5BGROUPINGS%5D%5B0%5D%5Bid%5D=125&data%5Bmerges%5D%5BGROUPINGS%5D%5B0%5D%5Bname%5D=Digital+Publications&data%5Bmerges%5D%5BGROUPINGS%5D%5B0%5D%5Bgroups%5D=&data%5Bmerges%5D%5BGROUPINGS%5D%5B1%5D%5Bid%5D=129&data%5Bmerges%5D%5BGROUPINGS%5D%5B1%5D%5Bname%5D=Events&data%5Bmerges%5D%5BGROUPINGS%5D%5B1%5D%5Bgroups%5D=&data%5Bmerges%5D%5BGROUPINGS%5D%5B2%5D%5Bid%5D=133&data%5Bmerges%5D%5BGROUPINGS%5D%5B2%5D%5Bname%5D=PMLiVE+news+alerts&data%5Bmerges%5D%5BGROUPINGS%5D%5B2%5D%5Bgroups%5D=&data%5Blist_id%5D=xxxxxxxxxxx
 
Key / Value pairs look like this:
 
data[email]    karl_2@karlequi.co.uk
data[email_type]    html
data[id]    xxxxxxxxxxx
data[ip_opt]    xxxxxxxxxxx
data[ip_signup]   xxxxxxxxxxx
data[list_id]    xxxxxxxxxxx
data[merges][ADD1]    Address 1
data[merges][ADD2]    Address 2
data[merges][ADD3]    Address 3
data[merges][ASSETID]    xxxxxxxxxxx
data[merges][CITY]    City
data[merges][COMPANY]    xxxxxxxxxxx
data[merges][COUNTRY]    Fiji
data[merges][COUNTY]    County
data[merges][EMAIL]    karl_2@karlequi.co.uk
data[merges][FNAME]    Karl_3DD
data[merges][GEO]    Europe
data[merges][GROUPINGS][0][groups]    
data[merges][GROUPINGS][0][id]    125
data[merges][GROUPINGS][0][name]    Digital Publications
data[merges][GROUPINGS][1][groups]    
data[merges][GROUPINGS][1][id]    129
data[merges][GROUPINGS][1][name]    Events
data[merges][GROUPINGS][2][groups]    
data[merges][GROUPINGS][2][id]    133
data[merges][GROUPINGS][2][name]    PMLiVE news alerts
data[merges][INTERESTS]    
data[merges][JOBTITLE]    Creative Director
data[merges][LNAME]    Equi
data[merges][TEL]    xxxxxxxxxxx
data[merges][ZIP]    Postcode
data[web_id]    xxxxxxxxxxx
fired_at    2013-02-07 15:31:14
type    profile
 
It fires on various events like subscribe / unsubscribe / update.
 
It's a most basic integration I'm after - just updating a users details when they are changed in Mailchimp. 
I've got it working from Matrix to Mailchimp - but Mailchimp always offers users the option to unsubscribe directly from the email - and that's the main data I need to pull back into Matrix.
Unfortunately even the most basic of data (ID) is coded in []
 
At the moment I can't see any way except somehow using php to grab the post variables and then submit them to a SOAP / REST matrix asset. (And that might be a stretch too far for my skills)
 
If you can think of any other options I would be most grateful.

At the moment I can't see any way except somehow using php to grab the post variables and then submit them to a SOAP / REST matrix asset. (And that might be a stretch too far for my skills)

 
If you can think of any other options I would be most grateful.

 

I was trying to think of something like %globals_server_QUERY_STRING^replace:/\[.*\]/:% which could clean up the brackets but that doesn't work.

 

Let me know if you need someone to write the PHP scripts, it should be pretty easy.