Page 1 of 1

Webservice.

Posted: Wed Jan 14, 2015 8:45 am
by mcbroh
Hi all,

I am 90% finished with my livecode app, but i feel i need to have a web service to make the connection secure.
1. Is there anybody who is good with web service that is willing to create the script for me (with a minimal price of :) )

2. how can i clear a local variable? i am trying to subtract one variable (50) from another (127) and store the result on DB, the result shown is (-447) so i have a feeling every value i place in the first variable has been adding up or something.

Regards
Mcbroh

Re: Webservice.

Posted: Wed Jan 14, 2015 6:50 pm
by jacque
For your second question:

put empty into varName -- use name of your variable here

Re: Webservice.

Posted: Wed Jan 14, 2015 7:12 pm
by sefrojones
For #1:

The first thing you will need is a server with LiveCode Server installed. I used a fresh ubuntu 14.04 installation on digital ocean as described in this link:

http://activethought.net/setting-livecode-server/

* If your server is running a different OS see the server guide linked below for installation instructions.

Once you have livecode installed on your server, you will need a basic understanding of how livecode server scripts work, there is a nice simple "hello world" example in the server guide(the server guide has all the info you'll need):

http://livecode.com/developers/guides/server/

Here is a sample server script for a MySQL databse:

http://samples.on-rev.com/database.irev

After you've messed around with some simple LC scripts, you will also need to know how to deal with input, here is an example about dealing with user input:

http://lessons.runrev.com/m/4070/l/3665 ... ode-server

And here is a lesson on passing data to a livecode server script by building a URL:
http://lessons.runrev.com/spaces/lesson ... r-scripts-

Most of what you'll need to know is covered between those lessons and the server guide. Once you have a handle on all of this, you can move the Database access portion of your app over into a LC server script and POST/GET your data to and from the LC server script. This way your database credentials are never exposed/stored on the end users machine. If you'd like to play around with LiveCode server scripting without having to set up your own server, you can check out http://thelivecodelab.com/

--Sefro

Re: Webservice.

Posted: Thu Jan 15, 2015 5:52 am
by mcbroh
Hi Jacque and Sefro,

Thanks you so much for the tip. Now playing around with webservices, will give it some shot and home I get a big smile afterwards :)

Re: Webservice.

Posted: Thu Jan 15, 2015 11:45 am
by Mark
Hi,

I can make a web service in PHP for you. Feel free to send me an e-mail.

Kind regards,

Mark

Re: Webservice.

Posted: Sat Apr 18, 2015 7:21 pm
by sphere
Hi,

i still don't get it completely though. I searched a lot also on stckflow and i see some examples.

My app is working great on Android to get some info from a MYSQL database on a non-profit war veterans site i manage, but it is probalby not safe enough do it like it is.
I'm just testing things. So it is a separate database next to the database of the website itself. I created a few windows apps to fill/edit/delete some rows in tables (these can work directly of my pc and do not have to be shared with anyone).
So the Android part contains all is needed to access the database, like username and password.(not safe because of reverse engineering?)

Now if you don't want or can't use livecode's server, then probably i have to create php scripts for each mysql command to get or edit the database? Like the commands now used in the script itself to get info from the database tables.
Because while i set access permission to everyone using % in the database settings. It seems not possible to acces it outside my own ip.
So the scripts will be seen as 127.0.0.1 correct?

Now i searched a lot but i can't find any example on how to use the GET command to pull info from the database and put them into a table or datagrid. i probably want to switch to datagrid because a table don't look to well on mobile.
So the Android part only has to read things from the database via the php scripts to have it more safe.

Does anyone have more info or point me somewhere how to use GET and how to put that in a field for reading?

Thanks a lot !

Re: Webservice.

Posted: Sat Apr 18, 2015 8:48 pm
by ghettocottage
Here is a good discussion about this, and at the end the guy has a link to a blog post he made where he works out some php scripts and explains how he did it:

http://forums.livecode.com/viewtopic.php?f=12&t=23614

and his blogpost:

http://learninglivecode.blogspot.com/20 ... eware.html

Re: Webservice.

Posted: Sat Apr 18, 2015 10:02 pm
by sphere
Now this is really appreciated !

Thank you very much Ghettocottage :)

Re: Webservice.

Posted: Sun Jan 08, 2017 12:18 pm
by UKMC
Hi everybody out there,

as Heather did strongly recommend to use webservice instead of direct SSL-database access for mobile apps, I have the problem that I have no knowledge about this technique :oops: .

In my opinion, out there must exist implemented routines for sending SQL-statements to the server and to transfer their results back.
This seems to me like a standardized function, independent from the database and the contents of the SQL-statements.
Normally, such a function brings some hassle with transferring of errorcodes, etc.

So I have the hope, that anyone is out there who has implemented this service for postgreSQL who is willing to share this function with me.

Any help would be appreciated very much :)

Best regards

Ulrich

Re: Webservice.

Posted: Sun Jan 08, 2017 12:42 pm
by Mark
Hi Ulrich,

In this case, a "web service" is a PHP or OnRev script that runs on a normal webserver (where you may also have your homepage). For instance, a PHP script like

Code: Select all

<?php
  echo 'hello';
?>
will return "hello" if you call it from LiveCode with the line

Code: Select all

put url "http://www.domain.ab/yourscript.php"
Now you need to add some syntax to the php script to get data from your database. You will probably find numerous examples elsewhere on this forum or you can start a new thread and ask.

Kind regards,

Mark

Re: Webservice.

Posted: Sun Jan 08, 2017 1:41 pm
by sphere
This is an old topic.
Meanwhile there was some progression.
See http://forums.livecode.com/viewtopic.php?f=12&t=27521
where PHP is used as middleware between your application and your database, these PHP scripts make use of PDO now which provide better security as MySQL statements are deprecated (but still used on some servers).