Retrieving JSON data from WordPress mysql database to android studio directly - php

I'm working on a WordPress e-commerce project that need to be converted into a mobile App.
I created few custom PHP files besides regular WP files where using PHP codes I'm sending products data by JSON directly from MySQL WP database.
But I'm facing two problems here:
1) If there are more than 20 posts/products in a wp_posts table then JSON page becomes empty but if they are less than 20 then the data are passing properly.
2) I think the process is not secure because the URL which contains JSON data are publicly accessable so anyone who knows the URL of JSON page will get access all secret data like username and password.
Question 1: Is there any other way to send data from MySQL to Android except JSON, also way to restrict access to JSON URL page publicly?
Question 2: Because this is an e-commerce website so there will be more than 20k+ posts/products, so will a single JSON page be able to handle those 20k+ data? 20+ data is turning the page black currently, so how to solve those issues? Thanks a lot.

Related

Fetch data from a dynamic website in Android

I want to access and display data from a website which is like a notice board, i.e, data content keeps getting updated at irregular intervals. Whenever any new content is updated I want the user to get a notification. The content updated might have links which I want to include in my app.
Initially I have to login to the access the data on which I found several satisfactory tutorials. The website is php based(link). How can I retrieve this data with minimal delay and in a readable format?
I have already read this.

Display SQL Data on a PhoneGap App - Possible Using URLs?

I'm building a web application using PHP & MySQL. A user profile displays MySQL data using a select query like so:
SELECT a.name_first,a.name_last,b.bio_category,b.bio_short,b.bio_full,b.profile_img
FROM stars_login a, stars_data_bio b
WHERE a.id_s=b.id_s
AND a.id_s='$select_id'
The $select_id variable is defined using ?id= in the URL like so:
http://localhost/public_html/profile/profile.php?id=1
I'm also looking at turning the web application into a phone app. I don't have much experience creating native apps as I'm more of a web designer.
I have however used Adobe PhoneGap before (cheating kinda, I know).
My question: is there a way to display a user profile in an Adobe PhoneGap app using a similar method to my exploded URLs in PHP?
Eg: there will be a search bar on my PhoneGap App home screen, where a user can search for a username. When they hit the search button they will be redirected to the profile view (similar to the profile.php page on my website). The PhoneGap profile page will then show the SQL data for the corresponding user.
I'm not sure if this is possible, but if it is, could you let me know how to go about it?
Also - how would I display the data that is stored server side on my local app?
I'm fairly new to all of this - I'm 18 and self teaching for a personal project of mine. All help is appreciated!
You can do this in your Hybrid app:
Create an HTML form which will serve as the front end to user
Use AJAX to send input from the user to your server
Process whatever pass parameter/s in that ajax request (such as the query you mentioned).
Return the result as json/jsonp then display the result back to the front end (no.1)

How to fetch data from external site to own site

I want to fetch data from live stock market to my web site. By using php and jQuery.
Has the source got an API you can work with to fetch the data? If so read their docs and implement it.
If not you could possibly do a Curl request and parse the data you need if your allowed.
More importantly you need to be more specific with your question if you want to get good answers, if any at all :-).
You need to find a web service that offers a stock market feed in the form of JSON or XML, so that your computer would be able to parse it. Not a website. Most of those feeds are paid - especially those that are close to real-time.
Then, once you have such a feed, you should be able to access it via your browser - just by typing in the URL. For example, http://www.quotewebsite.com/symbol=MSFT
This will help you understand what your server side script is supposed to do. Then, in your PHP script (PHP is a server-side programming language), issue a CURL request to download that specific page into your website's database (ex. MySQL). This will allow you to have historical data inside your own system. Then you get to render that data back to your own customers by querying your own database.

Form Hub Data Exorter

I have the website is hosted by Web Server. I use PHP and Mysql. And I also register and upload my data in formhub.org. Formhub allow us to export data to CSV.
My purpose, I want to automatic import the latest CSV file in Formhub or mean the latest data to my Mysql Database.
So When I upload data from Smart Phone through the customize From in Formhub.org, It will automatically update to my web base online.
How Could I do? Who can help me? Please Please give me the best solution and suggestion for this purpose.
Why not using the REST services formhub provides?
info at https://github.com/SEL-Columbia/formhub/wiki/Posting-To-External-Site
In this way, each form data is stored to your formhub and also by POST to a script anywhere you like and you can process it in your php (e.g your own mysql db).
with php you can collect the data with
$entityBody = file_get_contents('php://input');
like explained here: How to get body of a POST in php?

Getting data from MySQL to android and displaying as list under "App List" Tab?

I am a noob in android dev.. I have couple of questions..
1...I have database created in localhost in MySQL server. Table of all the "States".
Q2...I created PHP script to connect to the database, and getting the list from the database.. ...I need to convert this to Json file/data to be read in android...????
Q3...I created android project with tab views for list tab, getting & saving details tab, settings tab.. where details are settings tab are form view elements and need to write them back in json n send them to MySql database. how do i do that.. in php or android or both...?????
Q4.. When the user first installs the app and runs it, my app should send to the server the mobile registration id... how do it do that..?????
I tried C2DM, but no luck.. I am testing everything in the emulator first..
I am so stuck in these issues.. i have created more than 10 projects for each individual feature with the help of forums and blogs and google developer forums .. and yet dint succeed in anything..
PLZZZZZZZZZZZZZZZZZZZZZZZZZZ.... HELPPPPPPPPP!!!!!!!!!!!!?????
Thanks in adv..
Su
Q1. It is typical to use the json_encode() function to output a PHP array as a JSON object. This can be consumed by your android application by an AJAX call, passing in the URL to your PHP script.
Q2. Prepare an array of what you want to output as normal and then call json_encode() on it.
Q3. Look through the Android documentation and find a JSON encoding function. To 'send it to MySQL' you will need to pass the JSON output through an HTTP POST request to your PHP script that can validate the data and submit it to the database.

Categories