Webservice.

Creating desktop or client-server database solutions?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
mcbroh
Posts: 15
Joined: Wed Nov 19, 2014 5:05 pm
Location: Sweden

Webservice.

Post by mcbroh » Wed Jan 14, 2015 8:45 am

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4296
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Webservice.

Post by jacque » Wed Jan 14, 2015 6:50 pm

For your second question:

put empty into varName -- use name of your variable here
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Webservice.

Post by sefrojones » Wed Jan 14, 2015 7:12 pm

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

mcbroh
Posts: 15
Joined: Wed Nov 19, 2014 5:05 pm
Location: Sweden

Re: Webservice.

Post by mcbroh » Thu Jan 15, 2015 5:52 am

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 :)

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5132
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Webservice.

Post by Mark » Thu Jan 15, 2015 11:45 am

Hi,

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

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

sphere
Posts: 591
Joined: Sat Sep 27, 2014 10:32 am
Location: the Netherlands

Re: Webservice.

Post by sphere » Sat Apr 18, 2015 7:21 pm

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 !
Sony HitBit HB75P MSX-1, Amiga 500 v1.3, Amiga 600, Amiga 1200, Pentium 1 and onwards to all loose PC crap boards which already was in the Amiga for ages not mentioning the startup speed, which we now have again with SSD :D

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 250
Joined: Tue Apr 10, 2012 9:18 am

Re: Webservice.

Post by ghettocottage » Sat Apr 18, 2015 8:48 pm

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

sphere
Posts: 591
Joined: Sat Sep 27, 2014 10:32 am
Location: the Netherlands

Re: Webservice.

Post by sphere » Sat Apr 18, 2015 10:02 pm

Now this is really appreciated !

Thank you very much Ghettocottage :)
Sony HitBit HB75P MSX-1, Amiga 500 v1.3, Amiga 600, Amiga 1200, Pentium 1 and onwards to all loose PC crap boards which already was in the Amiga for ages not mentioning the startup speed, which we now have again with SSD :D

UKMC
Posts: 50
Joined: Sun Jan 08, 2017 12:01 pm

Re: Webservice.

Post by UKMC » Sun Jan 08, 2017 12:18 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5132
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Webservice.

Post by Mark » Sun Jan 08, 2017 12:42 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

sphere
Posts: 591
Joined: Sat Sep 27, 2014 10:32 am
Location: the Netherlands

Re: Webservice.

Post by sphere » Sun Jan 08, 2017 1:41 pm

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).
Sony HitBit HB75P MSX-1, Amiga 500 v1.3, Amiga 600, Amiga 1200, Pentium 1 and onwards to all loose PC crap boards which already was in the Amiga for ages not mentioning the startup speed, which we now have again with SSD :D

Post Reply

Return to “Databases”