Hi There,
I’m a total noob with Particle trying to reduce my noobitude be making a fun Internet Button webhook.
The first step is to get my login working and it seems to do that, but my subscribe handler method isn’t getting called. I see the appropriate data coming back from the server (it returns json of my user object from my back end, but the name of the event doesn’t match my expectations). I’m 99.9% sure that the login is happening correctly. I call the correct url, the data is correct, and there is A return value in the event log. Here’s my code:
void setup() {
Particle.publish(“status”, “in setup”, PRIVATE);
Particle.subscribe(System.deviceID() + “/login/”, myHandler, MY_DEVICES);
const char* data = "{\"login\":\"fake@spiralsix.com\", \"password\":\"fakepassword\"}";
Particle.publish("login", data, PRIVATE);
delay(5000);
}
void loop() {
}
void myHandler(const char *event, const char *data) {
// just publishes an event to see if the handler is called.
Particle.publish(“success”, event, PRIVATE);
}
Here is a screen shot of my event log:
The second line (lighlighted) contains JSON that is exactly the expected result of the call to login. It’s the json of my server user object. But what confuses me is that name of the even is “login/0” instead of “hook-response/login” (i think that’s what the docs said it would be.) So, how am I supposed to subscribe to that event, when the docs say it should be something else. subscribing to “login” doesn’t work.
Any help would be greatly appreciated.
Thanks community,
Peter