Fetching data using volley for specified search from android application - php

I have a doubt actually regarding volley in android. I know how to fetch data from sql server database through php code which does not take any data from the android app like
select * from table;
and if I'd like to fetch data from database with php code containing statements like
select * from tablename where field1='something';
I need to send data from android app to php. Can we actually do it using Volley. If so please tell me how to send data to php file from android.

HTTP library that you are using is not relevant in this problem. You need to allow for data input in PHP script. Either by POST or GET variables. (look at this tutorial http://www.tutorialspoint.com/php/php_get_post.htm)
In terms of creating request with proper parameters take a look at this question: Volley - POST/GET parameters

Sure you can.
Follow the official Volley guide, here

Related

How does RESTful work with PHP?

What exactly does a REST request do differently to a query when trying to get data from the database? I've been learning this and it only looks like a more complicated way of doing something for the same result.
If you are writing a REST service in PHP
Nothing.
REST describes how the browser interacts with the webservice over HTTP. How the PHP program supplying the webservice gets the data to respond with is irrelevant to the RESTful nature of it. If the data is in a database, you just continue to use PDO or some other database library.
If you are using PHP as a REST client
Instead of using a database API (like PDO or mysqli_), you use an HTTP client library (like cURL) and request the data using HTTP with the details of the request encoded in the URI (or the PUT or POST message body for UPDATE and INSERT-like query equivalents).

Accesing php web service and MySQL from Qt/C++ in android. How to send data to service?

I am pretty new with this. I am trying to develop some android application in Qt/Qml to query and update data to a database.
The problem I'm trying to solve:
There is a server with a MySQL database. The android application request some data. I use a very very basic php file that query in the database, format an XML and show that file starting with a header('Content-type: text/xml'); sentence, then some echo "<...>" sentences. This php file receives parameters via $_GET array and performs the query.
This is a little archaic but works fine. My client application use Qt/QML for android. It uses XmlListModel to obtain the data from the server and show that data in a ListView.
So far so good, but here is my real problem:
The user of the android application can change some data, and the modified data must be sent back to the server, who performs an update in the database.
My first attempt was to create another php file and send the data in the URI, get it via $_GET and perform the update to the database. This works but there could be many variables and the URI will become very large. I think might be better to send an XML (or JSON) from the client to the server, and put in that file the data for the update.
So, this is the question: How can I send an XML file from Qt/QML to the server? How does the php file obtain that data? Or maybe there is another, better way for doing this.
Every example I find just shows the server-to-client part, or is written in Java, and I don't know java enough.
Additional notes:
After I can solve this I will fight with security: SSL, avoiding SQL injection or anything, but that will be in another question if necessary.
I didn't use SOAP or similar because the first ideas was simple. Also, I have never used SOAP before. If this is the right way, I would be very grateful if you show me how to use it from Qt/QML in android.
Of course, I can use C++ for the client application since it is using Qt.
I use Qt since I already know it and the app might be useful in desktop as well.
Sorry if I made any english mistake.
Thank you in advance.

Android : Confused/Lost with Call a PHP webservice with Send & Receive

From my android app, I want to call php web services. At times, I just need some data from php, sometime get data based on some parameter passed. I prefer to use RAW Api like HttpClient. I also plan to use mySql DB.
To call php web services, I got references from http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/, and http://www.anddev.org/doing_http_post_with_android-t492.html, http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
I am STUCK at :
For eg: I pass 2 parameters with my url "http://......php?src=SOURCE&dest=DEST
REsult - Directions from SOURCE to DEST (at times result may be an array of strings, items, etc)
How to do send & receive data back in single request ?
How to write php for the same ?
Can the above accomplished using raw aPI or JSon or ksoap is required ? I have read that instead of using Jsoan or Soap, raw is the best approach.
Kindly help me to solve the confusion and proceed ahead wit hthe application.
Any help is highly appreciated.
Thanks
Yes,
alfasin, thru ur post and other sites I got things properly working.

Contact sync with android and php

I need to send all my contacts to server and return back only the contacts that are using my app.I am using HttpPost for sending data to the server. I am thinking of sending it as an string separated by delimiters or as NameValuePair. Is there any better way to do contact sync?
Are you using a database? If so create a php webservice that connect to your database, make a query and return results according the criteria you need. then you need to encode the result in a json array and use json to connect your android app and get the results, here is an example how to use json with android:
http://www.vogella.com/articles/AndroidJSON/article.html
There are many more libraries you can use: gson/json/jackson... all similar, you can make a search on google and chose the one you like better
Instead of json you can use SOAP, I have never used it but you can try : http://code.google.com/p/ksoap2-android/
Direct database connection is not recommended on android

Getting xml data and writing to db from external source

I have spent the past three days researching this... but Im still stuck.
I have a service provider that offers me a REST api. I need to:
Get the data from his api
Assign the data to variables in php
Write the data to my localhost sql database.
All that's required is the API KEY which has been provided to me.
Please could someone explain to me what method I should use to call and store the data in php.
Writing to the Database and handling the data once in php format is not a problem.
Thanks in advance
Since you want to consume a webservice you would have to make HTTP request using PHP.
There is many ways to do that but the most used(IMHO) is cURL. cURL function would allow you to easily make HTTP request and consume data from the webservice.

Categories