SambaPOS API Integration with NewBook PMS/Booking System

Actually that is probably wrong did you try that curl tool?

I downloaded it but little unsure what im ment to do with it.
Does it allow me to open the test html file locally with curl coding in it?
I am very obviously in over my head :worried:

Am trying outsourcing to india.
Is ajax ok in samba scripting?

Samba usings Jscript.

AJAX = Asynchronous JavaScript and XML.

http://www.w3schools.com/ajax/

Hmmm, google was auto correcting to javascript so maybe an additional cause for confusion on top of my incompetence in either.
Was thinking your were abbreviating Javascript :flushed:
So thats a No?

Not sure how to take this, to me seems like noā€¦ tried to lookup the difference but sounds like same base code but microsofts version of suns javascriptā€¦ but ajax not work with jscript what your saying?

Would gladly pay for someone to get the first call code which I can work off of !!
Anyone interested to take on the challenge?
Am ready to admit Iā€™m going to struggle to get going by myself and in over my head :sleeping:

Let me research it some and I will help you.

Any help is greatly appreciated.
Once the base script is layed down I am confident I can expand myself, just struggling to get off the ground.
From talking to a friend locally itā€™s the http auth on top of the api which makes it more tricky.

Its the authentication yes. We just need to figure out how they are handling itā€¦ It seems like some of their documentation is missing or they are assuming you already know.

Got connected with Rest easy Mozilla plugin pretty quickly.
The URL as listed with basic user/pass auth and the api as data entry but how that translates to script is beyond my abilities.
My friend said he might see what he can work out but php is more his thing.
Looking at your timetrex you were calling in from php files so will see if he can work something out in external file and try to use that like you have.

When you say documentation is missing something what would you expect to be there?
As I said before will request more info but canā€™t just say is something missingā€¦ Donā€™t want to sound even more incompetent that I do already here :frowning:

@JTRTech, maybe this link can help?

Hello. For next version Iā€™ve implemented web.PostData() function for JScript. Hope it helps.

3 Likes

Any ideas if http auth would work with http://user:password@url.com/rest format? :confounded:

Thanks for the link.

This is what I have at the minute

<script type="application/javascript">
function JSONTest()
{
requestNumber = JSONRequest.post(
    "https://sambapos:xxxxxxxxxxxxxxxxx@testau.newbookpms.com/rest/auth_test",
    {
        "api_key":"instances_xxxxxxxxxxxxxxxxxxxxxxxxx"
    },
    function (requestNumber, value, exception) {
        if (value) {
            processResponse(value);
        } else {
            processError(exception);
        }
    }
); 
}
</script>

Although am not sure what this bit actually does;

function (requestNumber, value, exception) {
            if (value) {
                processResponse(value);
            } else {
                processError(exception);
            }
        }

The <script type="application/javascript"> is because I am trying to remove variables and just using in test html file on my server.

Am just getting a blank page but sure thats because im not calling the functionā€¦ any sugestions?

You can test it from within Script design screen look at bottom right the small box. Look at Emre screenshot it shows how to type the function to test.

Which version will that be? .48 when uploaded?

No its available now.

You need to call the function. I doubt it will work anyway, since the StackOverflow article even states that JSONrequest is in draft, and not natively available to browsers, so they use jQuery library instead.

Calling your function in your HTML page is simpleā€¦ just call it.

<!doctype html>
<html>
<head>
<title>TEST</title>

<script type="text/javascript">
function JSONTest()
{
requestNumber = JSONRequest.post(
    "https://sambapos:xxxxxxxxxxxxxxxxxxxxxxxxxx@testau.newbookpms.com/rest/auth_test",
    {
        "api_key":"instances_xxxxxxxxxxxxxxxxxxxxxx"
    },
    function (requestNumber, value, exception) {
        if (value) {
            processResponse(value);
        } else {
            processError(exception);
        }
    }
); 
}
</script>

</head>

<body>

<script type="text/javascript">
JSONTest();                     // call the function defined above
</script>

</body>
</html>

Sorry JTRtech the post method not until next version so it wont do you any good atm anyway. But when its released you can test it like I mentioned.

@emre, how is web.PostData() different from web.Upload() ?

Maybe PostData accepts return value while Upload does not?