How do we get web.Upload or web.PostData contents on the other side

Hello guys, i’am In the process of implementing a solution for a client where samabapos will send ticket total to php script and based on the value from sambapos php script decides what profile the client should belong to. eg if i send like this in samabapos
function getWifi()

{

 var url = 'http://localhost:82/hotsport/index.php';

 var key = '{\"key\":\"small\"}';

 var response = web.Upload(url,key);

 //var responseObject = JSON.parse(response);

 //return responseObject.json.wifi;
 return response;

}

on the other side in php if i was getting this data from a form, i would get the value of key like this

if (isset($_GET['key'])) $key = $_GET['key'];

What is the right way of getting the post data of web.postData or web.Upload on the server side? Thanks

So i continued trying and i have ended up using web.Download not sure if the other 2 would yield same results, but so far with the below format in samba i am able to get desired response from server

function getWifi()
{
	var k = 283;

 	var url = 'http://localhost:82/hotsport/index.php?key='+k;

 	var response = web.Download(url);

 	return response;
}

Now how do i get to send my ticket total to this function getWifi() and how do i get the return value to print on my receipts?

$inputJSON = file_get_contents('php://input'); // listens for data POSTed to the site
$input = json_decode( $inputJSON, TRUE ); //convert JSON into array

From this post …

https://forum.sambapos.com/t/membership-api-integration/12205/25


Call the function using:

{CALL:handlerName.functionName(inputdata)}

And assign the “return response” from your script to a Program Setting or Ticket Tag or similar.

Thanks a lot Man, it all worked perfectly, so right now i have a button that i have been testing with when the ticket total is 15 and above it will add the tag with the wifi credentials.
image

I dont have a printer to check how this will look like, as i would like it to be as visible as possible. Do ticket tags print to receipt by default or i will have to modify my ticket template? I am also wondering what would be the best event to add this fuctionality too, perhaps ticket closing.

Thanks man at this point i will figure out the rest, my client will be super happy!!!

By the way i am using Mikrotik router which generates the id and pass in a specific profile that limits bandwidth and amount of time for access… super cooool. SambaPos Rocks!!!

You need to modify the Template and use:

{TICKET TAG:tagName}