I know this isn't the best place to talk about android applications but please read on.
Background:
Myself and two of my class mates are developing an android application as part of one of our senior projects for a class. My job in the development is going to focus on the back end. I will need to log in to a website and return information found after logging in like school schedule, nothing illegal. This will all need to be done through coding, the user will not actually be on the website.
Thought process:
I was planning on making an http request to PHP script that I have stored on a web server which will do all the heavy lifting and then pass the required information back to my partners who will use the information in the application we're developing. I have limited experience with http requests which is why I'm trying to learn this part early on in the semester.
I've done something very similar to this using html and Javascript. But I'm not sure if what I'm planning is even possible in android development which is very much like Java. What I did last time was use an http.open(get, url) type of operation to send information to a php file. I did not send any information back once the php script was done running so that is something else I will need to learn to do.
My question:
Does anyone know if what I'm planning will work on an android platform?
Is it even possible to pass info to a php file and then pass info back?
I have not been able to find much info on the http.open method in other languages, does this method exist in java or a similar method?
Resources I've found:
Android HTTP documentation
If anyone could push me in the right direction or pass me some reading material that would be very much appreciated.
3 replies to this topic
#1
Posted 08 February 2011 - 02:03 PM
|
|
|
#2
Posted 08 February 2011 - 03:01 PM
I believe a good tutorial that sums it up is here: httpurlconnection - How to use java.net.URLConnection to fire and handle HTTP requests? - Stack Overflow
There are links also to tutorials and examples of Apache HttpComponents HttpClient if that is more relevant to your Android device. From what I am reading, I believe you wish for the PHP page to maintain a login session with a website, you can achieve this through your own method or a method such as utilizing the CURL library, which can store cookies and send them with each request as to maintain a session, more CURL requests can be made to further download the required schedule.
I am not sure what you mean about send and send back, a GET request from the android will tell PHP to do all that and send back the required data to your Android if that is what you mean.
There are links also to tutorials and examples of Apache HttpComponents HttpClient if that is more relevant to your Android device. From what I am reading, I believe you wish for the PHP page to maintain a login session with a website, you can achieve this through your own method or a method such as utilizing the CURL library, which can store cookies and send them with each request as to maintain a session, more CURL requests can be made to further download the required schedule.
I am not sure what you mean about send and send back, a GET request from the android will tell PHP to do all that and send back the required data to your Android if that is what you mean.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#3
Posted 11 February 2011 - 03:29 PM
Thank you for the quick reply. I have spent some time with the android development process and have completed a few tutorials. I'm now to the point where I want to get a test php script setup that my application can access. I will now spend some time looking over the resources you posted.
And to answer your question, I don't really need to keep a connection open, I just want to fire some php script remotely using an http request. The php script will then scrape information off of some webpages and then return some information to my app. I possibly don't need to do the scraping on remote php script but it seems easier atm, but I may end up doing all the scraping in the app itself. And yes, I plan on using a Get request to ask my php script to return some data back to my android app.
And to answer your question, I don't really need to keep a connection open, I just want to fire some php script remotely using an http request. The php script will then scrape information off of some webpages and then return some information to my app. I possibly don't need to do the scraping on remote php script but it seems easier atm, but I may end up doing all the scraping in the app itself. And yes, I plan on using a Get request to ask my php script to return some data back to my android app.
#4
Posted 11 February 2011 - 03:46 PM
I think I need to take a deep breath and a step back. I'm starting to think I'm going in the wrong direction.
I can scrape information off a web page just fine using an http connection in the java/android environment can't I? I'm making more work for myself by having a PHP script do this for me remotely aren't I?
*EDIT*
Ignore my banter. I've been able to successfully access my php script through the android app. I've discovered that what gets returned is the page source code so this leaves me some options. With this first step done, I'm starting see possibilities ahead.
I can scrape information off a web page just fine using an http connection in the java/android environment can't I? I'm making more work for myself by having a PHP script do this for me remotely aren't I?
*EDIT*
Ignore my banter. I've been able to successfully access my php script through the android app. I've discovered that what gets returned is the page source code so this leaves me some options. With this first step done, I'm starting see possibilities ahead.
Edited by BoostHungry, 11 February 2011 - 06:07 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









