Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Apologies for the general question, but it is an area I am having trouble even starting with.
I'd like to write a basic android app for a smart phone that sends a simple string over HTTP to a web server.
The client side of this is fine, but I don't know where to start with the web server part - here are my questions:
On the server side, how do you capture the data received on the web server from the smart phone? Is there a recommended programming language or script where I can capture the string sent from the smart phone?
for such a simple task, do i still need a full web server, or is there a recommended lightweight one?
Is there a way of testing where I can send a string to the webserver, and a webpage can print out a list of strings it receives in real time? Would Ajax be appropriate for that?
Thanks a lot, any guidance much appreciated.
As #cybermonkey said, you should communicate via HTTP POST. Http Post lets you send data (large bits of data), you can use the headers actively to determine response status etc.
When using POST, I would recommend transporting the strings in JSON-format. JSON Allows you to serialize and deserialize objects, arrays and strings. Can be serialized and deserialized at both ends, so you can transmit data in both directions.
You need a language to receive the data from the mobile app. I'd recommend either the language ASP.NET or my personal favourite PHP. They are both decent web-programming languages.
In order to run these services you need a web-server. There are alot of web-servers out there. The most popular and easy to use is probably Apache / httpd. (Nginx can also be recommended - but is more difficult to work with).
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
My Android app calls for some data that I have stored in my database. I've worked with some Java Dynamic Web Apps, wherein they'll use cxf and write web APIs, catering to the requests. This seemed like the obvious idea for me to take up. So I wrote my REST API, used Jersey, and everything seemed to be working fine.
But then I checked out the cost of hosting a Java app on server, and then I decided to write the API in PHP. I thought that REST was basically just providing different URLs. But then I came across this tutorial here. In this tutorial, the author just makes call to normal PHP files, and that's it. I am echoing JSON encoded data in my PHP script, that I get back. This does not sound very RESTful to me. Maybe because I don't see /getClientInfo,addClientInfo kind of URLs.
Calling normal PHP scripts is just so normal. What did REST add to it?
In short: it does not matter. At all.
The actual API here is an HTTP interface. The web server this all runs on is the API. You're just dressing it up differently by using different URLs or possibly different protocols on top of HTTP, e.g. SOAP or such. But fundamentally nothing changes, you're making an HTTP request and you're receiving data back in an HTTP response, period.
REST is simply one way to structure your API's URL names and parameter conventions etc., and a way that makes sense in the context of HTTP. But it's not the only way and by itself REST doesn't do anything that's absolutely necessary or not doable any other way.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
From my android app I want to get some data from my table containing two columns in my online MySQL database. Could someone explain me how to write a PHP script or something what I need that would respond to a call from my Android application by getting some values from my database and returning it to my app? And then how to call that function from my application and how to handle (save in my app) the returned data? HUGE HUGE THANKS in advance!
There's not a built-in MySQL connector for the Android framework, and even using an external jar for this is discouraged. The best way you can accomplish this is via a webservice in the remote server, so instead of sending direct MySQL queries to a database, you'd send a HTTP POST to the remote webserver (for instance, written in PHP, Python or whatever you want) and this would connect to the local database and make the query.
I think this example might help you.
When you make the http request to the php script, you handle the request based on the method you sent, GET or POST.So for example
$id=$_POST['id'];
From there you do whatever server side queries to get the needed information. When you are done, simply echo the response back. I would recommend using JSON as the format as its easier to deal with.
echo json_encode(array('success'=>true,'data'=>$data));
You can extend the SQLiteOpenHelper class to write your own sqlite helper interface.
Try following some tutorials on Android's site here.
Or follow a neat tutorial here from vogella.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
My team is going to make application in android having quizzes on mobile whose questions,options would be entered from my website. I want to be able to enable the new quiz from website end.
Going to code website in PHP. I'm good at wordpress so just wondering if I can do this in that only or not as I don't in what form I have to convert my data so that android can get it and use it in "native app"(not browser!!).
my job is only the website part I know how to make pages but don't know in what form I have to give quiz data and how to control enabling and disabling the quiz in mobile app
thanks for the help in advance...
There are several ways you can transfer data through different applications/technology.
Some ways that appear to be straight ahead to me:
The Android App can parse your generated HTML file directly and extract the questions and the options parsing the HTML tags.
The Android App can also connect to your website DB and get the information directly from that.
You can also expose your data creating a services using WebServices or ODATA, for example.
I have to say I've only ever dealt with Cordova for writing apps but if Cordova can do it...
In the app I wrote for an internal application I used an AJAX call (Cordova uses JS + HTML as its interface). My PHP server then returned a response my app could use (in my case, JSON) It sounds like this is what you want to know. Now your app team will have to tell you what format to send your response but it's possible to have apps do this.
This would have to be done in PHP(EDIT: or any other technology as such) since your team is working in PHP already. To enable/disable the "new quiz", the app would have to query the server for this information, which would come from the Database.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have inherited a php site that is returning HTML pages. I always thought that the server returns data to the client and the client decides how to show the results.
Even though this is working, is this not a very tight coupling between the server and the client?
I would have thought a much better way to handle this is for the client code, javascript or gwt or what have you to ask for the needed data and the server returning that data only such as JSON object or a similar thing.
Thoughts on this?
It sounds like you could benefit from making an AJAX call (via js) to a php page, then manipulating the data (JSON object, string of comma delimited data, raw HTML, etc.) returned on the client side.
Sorry for the bad previous example, this example is a more sophisticated, modern example of how an ajax call should be made.
It appears that it is not at all uncommon for php scripts to return HTML. It does create tight coupling with the client application. Returning JSON does create a more loosely coupling with the client.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am building a small business which revolves around a complex form. So far, I've been developing the form in Javascript. However, the fact that js is client side pretty much means all my efforts are exposed to possible theft. I've looked into obfuscation techniques, but due to the fact that there are de-obfuscators out there, securing the intellectual property is dicey at best.
Is there any way to secure my js code from theft? Is copyrighting or trademarking the code a feasible alternative? This project is pretty much of a niche, so if a competitor who used similar code suddenly appeared, it wouldn't be all that difficult to check. However, if someone else used my code as the basis for a server side app, then I'd be pretty much screwed. If js is not a viable language to develop in, is there a server side language which could do the job? What pitfalls await the project on the server side?
Any help would be appreciated!
Here's how to secure your intellectual property from theft: Don't write your code in client-side javascript.
The choice of server-side language is a bit broad in scope, but if you prefer javascript you can implement your "secret/proprietary" functionality as a webservice using Node.js and then make calls against that from your actual form (either via traditional postback or via AJAX).
Assume that any Javascript code can be read by a human, no matter how much obfuscation you put in. If a web browser can interpret it, a human can.
Generally any sensitive data should be stored on the server side and any sensitive business functions/calculations should reside on the server side. You can still achieve the client side smoothness and feel by using AJAX to call the sensitive functions on the server side.
There is no "most secure" server side language. Use the one you're most familiar with and is most suited to your app. Web application security correlates with the developer and their knowledge rather than the actual language.