get httppost response like when using inspect element in chrome using java - android

I'm sending an httppost request to a web site (asp) and I'm trying to find a table in the HTML source by using EntityUtils.toString(httpEntity, "UTF-8") but I can't find the table that I'm looking for.
BUT, when I'm clicking on inspect element in chrome for the same web page I can see a whole new world which contains my table and a lot more.
Is there a way to get the same raw data as in Chrome's inspect element in an android app?

Chrome handles cookie and session management automatically, along with typical connection management aspects (eg: cache, keep alive, etc)
Make sure your android app is making the http post request with all the necessary headers, cookie/session, and input parameters.
You can use chrome dev tools to capture and see the full request/response detials. See if its sending any cookie information to the server. If so, you will need to modify your android app to do the same.

Related

automating filling out a websites form in a java android app

I'm working on an android app that on buttonpress fills out the form data on a website, submits those and returns the response in a webview.
I tried many solutions based on all input elements the website expects.
I also did record the network activity in chrome's developer tab when I submit manually, tested it with only those parameters, and even imported the .har in POSTMAN.
Whenever I try to recreate the submissions either via POSTMAN or via cURL, I'm getting the 403 Forbidden Errors, no matter if I use POST or OPTIONS..
I'm guessing I am missing a Session Cookie or something equivalent.
Frankly I'm fairly new to this topic.
How would I generally go about automating the filling and submitting of forms on a website while still retrieving the response in a viewable format (e.g. to be able to manually enter the captcha)?
The URL in question is this btw: https://subwayrewards.de/register

How to set programmatically cookies using Crosswalk XWalkView?

I need to make a webview application that POST a username and password and then display the webpage logged-in. I must use cookies but i chouldn't find how to do it, tried the traditional ways but nothing.
Has anyone had any experience with xWalkView and how to get/put cookies ?
(I am using xWalkView since the traditional webview on android 4.2.2 can't load HTML5 webpages)
I had the same problem but I did not find the exact answer. Instead, I found a kind of a work around.
As I am using a servlet container, I append a ";jsessionid=" to every request I make to the server.
The other thing than can actually work for you regardless of what backend you use is to make a request to your web server so that it returns a response with a cookie.
For example if you want to add a name=test you could make some xhr request to some url and the response must have the cookie name=test in it. This technique also work for me for session tracking in my java app.
Good luck

POST form from jquery-mobile (android app) to a cakephp website

I search a tutorial for learn how to send data from an android application (simple form - application builded with jquery-mobile) to my website under cakephp. I see the JSONP technology, this is the good way, no ? or there is more solutions ?
JSONP is one way to achive Cross-Domain resource sharing. It is easy on server side just wrap your JSON response with
callback(<-JSON->)
and on client side have unction named callback that take json in argument.
You can also simply change server config to allow all origin so that you won't run into CDRS.

Developing a server to host a smartphone app content

Im building this app (using Unity3d) for a city hall and I need to split the content from the actual app since content must be easily changeable without having to update the app itself.
I want to host the content on a server and use http get/post messages to retrieve the data. I also need to have a web editor (kinda like a CMS) so that the client can change the content himself.
In the editor I would just have a list of "rooms", where each "room" would be one of three types (i.e. text screen, slideshow or audio). Depending on what type the room is, different parameters should be visible and editable.
What language you suggest I write the server in? (the server that the app would contact in order to obtain the up-to-date content) Python i'm guessing here?
What would be the easiest way to build the browser editor? Javascript and django?
If you know Python already and don't want to have to support maintaining a web server for your client it would probably be easy to host the web portion of your app on Google's App Engine. It's relatively easy to use App Engine to serve a simple a web form where the client could edit content and upload binaries. The form could be built using Jinja or Django-style templates, and the data would be written to App Engine's datastore. (also, it's easy to restrict access to the form to app administrators to prevent accidental/malicious edits)
Then the Unity app would query a page on the App Engine server to see if there's new content using the WWW object. The server would make a quick memcache/datastore query and return a JSON response telling Unity if there's more stuff to download or not.
I've done all of this in past projects, so I'm sure it's workable, and a lot of relevant code can be found in App Engine's tutorials and via some light Googling.
I would also look at Wordpress as a CMS. You can create custom forms for different post types. Each "room" type could also be a category type and have custom fields for data to be inputed.
There are loads of plugins to get up and running without too much coding. But you can also dig in and customize with some PHP coding.
The great thing about Wordpress is that media handling, Database interface, user management, privilege and editorial controls, to hand off to a client, are all there. There are loads of tutorials and documentation to get the platform to work for your needs.
Android get connected easily with cloud server.I don't know about others. You can connect using JSON and PHP for this.
You can use .net platform as an backend server.
You could also build Webservices. On my project we work with it. You could also do it with PHP. Try this link: Androidhive.info/how-to-connect-android-with-php

Android web app

What are the best ways to connect site and show it's data on an android application ? Also does I have to create anything on server where the site is for using JSON ? I am new to programming web android application's, though I searched a lot I didn't find anything which would explain me straight to the point.
You're on the solid ground starting out using JSON as the interchange between the two.
Alot of popular mobile apps like Twitter and Foursquare have restful APIs set up to interact with their mobile clients by exchanging HTTP requests that contain data formatted as JSON. Most of the communication between the two can be accomplished with HTTP requests using the standard GET and POST methods.
A good place to start would be setting up some server endpoints that output this data and then setting up your android app to request and parse this data just like a browser would. You just need to set the appropriate mimetypes on your server end (application/json).
Most modern server-side languages have implemented modules/functions that can take their native data structures and approximate them in serialized JSON (PHP's json_encode(), python's json.dumps() etc) These can be used to output data from within the app or database to your mobile client where it can be interpreted and used in the Java environment there.
To pass back JSON you need to set the mime type (http://stackoverflow.com/questions/477816/the-right-json-content-type), which is application/json.
If you are passing back JSON or XML then the client just needs to make the appropriate http call, most likely GET, perhaps POST, to actually retrieve the information.
You can use something like this as a starting point:
http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/

Categories

Resources