#Server is sending parameters to the url

1 messages · Page 1 of 1 (latest)

thorny jetty
#

Hey there,
I am seeking guidance as a server is sending the parameters to my api url. And I'm trying to get those 2 params sent by server.
Server sending this type of log whenever i generate a new booking: "Dec 12 16:41:54 x1 wcron: [-] postNtimes: Posting done, url= b'wubook.revroo.io/push-notification';, params= {'rcode': 1670859713, 'lcode': 1669807740}"
Using Request in my code i can only fetch the manual added params by myself, can't fetch the params receieved from server in url.

public function url(Request $request)
{
$rcode = $request->has('rcode') ? $request->rcode : null;
$lcode = $request->has('lcode') ? $request->lcode : null;
return response()->json([$lcode,$rcode],200);
}

Its retuning {null, null} in response because I have not added manually params in url. However I can't find the method for fetching those POST params.

mellow condor
thorny jetty
#

No no, I'm not posting data.
I just want to get these params that has sent to my url:
Posting done, url= b'wubook.revroo.io/push-notification';, params= {'rcode': 1670859713, 'lcode': 1669807740}

mellow condor
#

i dont understand 🤷 you have to add the params in postman..

thorny jetty
#

Everytime I add a new booking in server the server sends the attached url the reservation code and hotel code.
Like this:
Documentation: "Once a new reservation is collected for the property identified with the lcode argument, WooDoo will issue a POST to the relative URL containing two parameters: rcode (the reservation code) and lcode"

#

I want to get the params key, not manually adding them.

thorny jetty
#

@rancid willow Yes

rancid willow
#

And why are you trying to send requests in Postman if this is clearly a webhook that some other party should be sending you?

#

Like, what are you even trying to do here?

#

I’m utterly confused.

thorny jetty
#

Let me tell the flow.
I'm working on booking server:
1- I add a booking.
2- Server receives the booking and send the {lcode, rcode} to the attached URL.
3- I've attached "wubook.revroo.io/push-notification" url in my server. So, that whenever I add a booking it send me the lcode, rcode in this URL.
4- I'm using Request in my code to fetch those sent params with URL in my code.

#

My code is able to get only manually added params inside the url. But I can't find a way to get these params sent by server to my URL.

rancid willow
#

What is “sender”? A third party service?

#

Because if it’s a third party sending your server webhooks, then I fail to see what dicking about with requests in Postman is going to achieve? There’s no guarantee you’re going to 100% emulate a request send by this third party.

thorny jetty
#

Wait wait there's no third party.
Wubook server provides us service that whenever any user from anywhere make a booking, the server send us the information like {rcode(reservation code), lcode(hotel code)} to any URL that we have added to get notification of new booking.
That's why I made this api/url through which I am trying to get the lcode, rcode sent to us.

#

Forexample we confirm the URL added to our property using this API.

rancid willow
#

Wait wait there's no third party.
Wubook server provides us service that whenever any user from anywhere make a booking, **the server send us the information like {rcode(reservation code), lcode(hotel code)} to any URL that we have added to get notification of new booking. **
That's why I made this api/url through which I am trying to get the lcode, rcode sent to us.
Literally the definition of a webhook.

mellow condor
#

Nah its a Lalarukhook

rancid willow
#

If it’s a POST request, set the fields in the actual body. You’ve already been told.

#

Query string parameters are for GET requests.

thorny jetty
#

@rancid willow Still this using POST
My code is returning null because I'm using Request. And request works for manual added params.
public function url(Request $request)
{
$rcode = $request->has('rcode') ? $request->rcode : null;
$lcode = $request->has('lcode') ? $request->lcode : null;
return response()->json([$lcode,$rcode],200);
}
I want to find a way to fetch the params received from server in our URL.

mellow condor
thorny jetty
#

I don't want to post any param to server. /

rancid willow
thorny jetty
#

I want to get those params

rancid willow
#

It seems you’re missing a fundamental understand of how HTTP requests work.

thorny jetty
#

When I add in the body tab. It returns only manual provided params.

mellow condor
#

yes because you are making a request with that data to the controller you showed above

#

you cant make it magically come up with some values to return out of thin air

thorny jetty
#

@mellow condor exactly

mellow condor
#

you are just not understanding how HTTP requests work

thorny jetty
#

@mellow condor May I have your guidance that except HTTP Request any else method through which I can fetch those params in my URL response?

mellow condor
#

I don't think you are clearly or correctly describing what you are trying to acheive either. Postman is for testing/documenting apis.

#

If you have another service sending data to that url and you want to log it for future use then you should save it to the database or store it somewhere.. all you are doing atm is returning data that is sent to the url.

thorny jetty
#

@mellow condor
These are the logs generated by server after adding everytime new booking:
"Posting done, url= b'wubook.revroo.io/push-notification';, params= {'rcode': 1670859713, 'lcode': 1669807740}"
I know HTTP Request isn't made to fetch these received params.
I also can't find any other way to just get these 2 keys(lcode, rcode)

mellow condor
#

Fetch it where and for what purpose? You likely need to store it somewhere and access it from where you store it via a separate url.

thorny jetty
#

Got it.
May I have a bit more guidance, like how can I store these incoming values, how can I call it. As its particularly coming to only this URL.

mellow condor
#

store it in the database/ broadcast it / dispatch a job to trigger the needed actions
rcode (the reservation code) and lcode (the property identifier, allowing to use the same URL for multiple properties).

if you just want to react to this informing you of new reservations then you should process using any of the above. If you need to get more information about the reservations then you could do that inside a job and call their API

thorny jetty
#

I've browsed a lot, except Request module I can't find a way to store it.
The url is not like "url.com?params=1&param2"
This is the plain added URL "wubook.revroo.io/push-notification" which is receiving the params.
https://tdocs.wubook.net/wired/fetch.html#setting-up-the-push-notification

if it was like url.com?param1&param2 then I could easily store them. But they're not visible. I'm stuck in the middleware. Once I can store them using a code then I am able to do everything.
But I can't find a particular function or module to call that received param and store it.

mellow condor
thorny jetty
#

But @mellow condor my code is storing only null.
its not storing the received values.

mellow condor
#

Your not storing it anywhere though your just reading the request and returning it your not storing it.

thorny jetty
#

Shall i switch: "$lcode = $request->has('lcode') " to the "$lcode = $request->get('lcode') "?

mellow condor
#

I honestly don't know if your trolling at this point

thorny jetty
#

No @mellow condor
I'm an intermediate developer in laravel.
That's why asking for functional building of it.

mellow condor
#

You need to follow laravel from scratch and gain some basic understanding then

#

I would say this is basic stuff not intermediate

#

What in the code above makes you think you are storing it anywhere?

thorny jetty
#

@mellow condor I apologize. But I am honestly seeking your help.
You're right, i got the point that I am just reading the request and sending it as response.

thorny jetty
thorny jetty
#

Kindly give this a look, is this approach fine?

"public function callurl(Request $request)
{
$role = $this->url($request);
}

public function url($request2)
{
    $rcode = $request2->has('rcode') ? $request2->rcode : null;
    $lcode = $request2->has('lcode') ? $request2->lcode : null;
    return [$rcode,$lcode];
}"
mellow condor
#

What do you think this is doing?

thorny jetty
#

This is sending the HTTP Request to the url function.
And url function after getting request storing the rcode, lcode and returning it.
Then callurl function can have the stored values inside the url function.

mellow condor
#

No nothing is being stored still.

#

Your just calling a function and it is returning a value.

thorny jetty
#

I'm very sorry, but I want to ask this. That through which approach I can store it?

mellow condor
#

You need to learn laravel

#

No point going any further