Particle Webhook to PHP URL problems

I’ve set up a Particle.publish from my Photon like so:

sprintf(publishString, "{\"location\": %u, \"aRead\": %u}", location, aRead);
Particle.publish("trap", publishString);

I want the data of location and aRead to be inserted into a php link like so: …/RegisterValues.php?locationId={location}?value={aRead}

I’ve set up a webhook in Particle in many different ways, but I just can’t get it to post the data into my database.

I’ve tried Full URL: …/RegisterValues.php and changing the parameters in the publish string to that of my database columns. I’ve tried the FORM and Query input, but I just cannot get it to work. My current setup is like this: image

What I want to happen is the data from my publish string {{location}} and {{aRead}} is being placed in my phpmyadmin database under controllerId and value respectively.

I would use the query parameters and set:

controllerId={{aRead}}
value={{location}}

There are some tips of using Mustache templates in query arguments in this tutorial:

I’ve already done this under query, but this doesn’t give me

controllerId={{location}}
value={{aRead}}

but

{
  "controllerId" : "location"
  "value" : "aRead"
} 

I’ll experiment with getting your code into the webhook and I’m gonna check out your tutorial now.

I’m completely confused. If I just use the link …/RegisterValues.php?controllerId=2?value=50 in my browser, it inputs these values. But with change the names of the strings in the Particle.publish to fit the right columns in my phpmyadmin database, there’s literally nothing happening…

In requestbin it just shows me what I would expect: {"controllerId": 2, "value": 6}.

If you can enter the values in your browser URL bar, you need to be using GET not POST. And set the values as I entered above for query. Include only the part before the ? in the URL for the webhook.

So, as controllerId={{location}} opposed to "controllerId" : "location"?

And going to try that now.

Wait, how are you entering these values? In the graphical UI, the custom JSON tab, or using the CLI?

I am using https://dashboard.particle.io/user/integrations to create the webhook. Been using the interface the most since I have no experience with JSON and I figured this was going to be an easy task, I was a bit wrong about that.

This is what I meant:

1 Like

It worked! And I found a problem as well, the documentation of the input values had a mistake. It was controllerid, not controllerId…

Anyway, super thanks for your help. I don’t think I would’ve known about the GET instead of the POST. :smile:

1 Like

@Len Hi! I’m hoping you could provide some direction…
I’ve got the webhook running - it’s returning a url in the webhook console ‘HTTP Response’.
I can use json_decode to display my sensor data on the php page if I manually append the hook response url to my hosted php url.

I’m at a loss for what happens next - how are you using the webhook to update your DB in phypmyadmin?

Thanks for any help you can give!