I'm trying to make a http request and get the full page as string.
After I got response, I'm trying to find the position of a substring in it.
But I can't find that substring in the response whereas the original web page contains that substring in Google Chrome -> View Source. (Checked in mobile version).
So, my guesses are:
1) Maybe It's not requesting the mobile version of that web page? If it is so, how can I change my user agent to a mobile version? like chrome android?
2) Is it possible that response does not give me the full page? Because, when I try, LogCat isn't showing the full page.
Thanks.
Try this
1) http://www.intertech.com/Blog/android-defaulthttpclientandroidhttpclient-and-httpparams/ this will help you for changing user agent.
2) for logging try to log your response like Log.d("Reponse is: ", response);
1) Yes you can set the user agent by creating your client like this:
HttpClient client = AndroidHttpClient.newInstance("MyAppUserAgent/1.0");
2) You would need to post the code, but logcat will not necessarily dump the entire response. There is maximum length per log and text is clipped to that length.
Related
My scenario is this: we point the user to a form where they fill in the data (3DSecure) and then POST, the website then POSTS the response to a callback URL - this response is what I want to capture. WebView.shouldInterceptRequest() can get the headers but not the content (Why, Google?). I tried this link and it can get the POST data that the user sends. Is there any way to use Javascript to catch the POST data being received to a callback of my choosing?
I saw this post from 5 years ago and the man resorted to POSTing the response back to a server and then getting the contents from the phone. This is far from ideal. Surely there's a newer solution?
shouldInterceptRequest() mentions that a response contains the "response information or null if the WebView should load the resource itself", how do I get it so that the WebView shouldn't load the resource itself? The source code seems to return null always.
I used this gentleman's library: https://github.com/LivotovLabs/3DSView
If one was looking to do this with something other than 3DSecure they could use it as a template.
Currently I'm developing android application that needs to connect itself to REST API. It is crucial for my app to access API whenever connection is possible (mobile data/wifi).
But when testing my app something extremely weird happened. Application works as expected almost all the time, but when on VipMobile operator (Austria telekom group) I cannot connect to API.
At first I didn't get it, error was too unreadable. It says
j u fehler6 the requested item could not be loaded & wrong mime type
There are a lot of unprintable chars in that message too. When i figured out that it is operator fault i tried to copy link to my API and got this.
What could that possibly be? Can anyone point me in any direction, I cannot publish application as long as there are those ridickulous errors.
This happens when the user is on 3g connection. Some mobile operators intercept clients request and if the Content-Type is not good, or not defined they display page like this. This happens also to vipmobile operator in Serbia.
Try to add right content-type to response headers on your server side.
Try to put for example Content-Type:text/plain;charset=utf-8 to headers
Android 2.3.3
The documentation of Millennial Media says that I can use a HTTP GET Query to get the AD as a HTML Response.
My client application needs the ads to be embedded in an article, that comes as a response from server. After getting the response, we construct the page, using HTML tags and display it in a viewpager. While constructing the page, since the response is HTML, i can add it to the page before it gets displayed.
To construct a HTTP GET query, we need to have
APID The Ad Placement ID.
AUID The Unique Identifier for the device.
UA User Agent.
UIP The User's Public IP Address.
Where do I get the above to construct the GET query,
APID - from the mmedia site (in my account)
AUID - ?
UA - ?
UIP - ?
How can I query these details?
If someone has previously done this or has an example or a link, please guide me.
EDIT :::
#Millennial Mark
Thanks for the help. Now I have, APID and AUID. I am building this on the client side. So, I can query your server with just these two values and I get a response. - Understood till here.
So assuming my apid = 123149 and auid = eeabcef75ce706b4, my url would be,
http://ads.mp.mydas.mobi/getAd?apid=123149&auid=eeabcef75ce706b4
that's it. No other data needed?
Next question is :::
Can I query the server, with what size of the AD i want. For example, if the app is running on an tablet, I would need a larger banner (for ex: 728x90) than the one I display on the phone(for ex: 320x50). So, can I send the needed banner size along with the HTTP Get request? If so, how?
If I still have questions after this, I will use the support ticket.
I've seen a few integrations done this way-- usually in a server-side language like PHP, JSP, or ASP. Depending on what server-side technology you're using, where these variables come from is going to look different. The UA (user agent string) and the UIP (user's external IP address) usually comes from an inbound HTTP request headers. PHP, for instance, has a variable called $_GET for retrieving these parameters so you can pass them onto your Millennial API call. In these cases, it's acceptable but not optimal to pass the same value for AUID as you do for UIP. Then, you can echo out the response of your call to Millennial onto the webpage on its way into your app.
On the other side, if you're trying to build this into your Android app ("client-side")-- getting the AUID is as easy as calling Secure.getString(this, Secure.ANDROID_ID); and UA and UIP can be omitted since your WebView object will populate them in their request headers, and Millennial's servers will be able to recognize them.
If you'd like more guidance (since Stack Overflow is more of a Q&A environment and not a discussion board), I recommend putting in a support ticket at https://tools.mmedia.com/user/supportDevPortal
I am hitting my Exchange server using (EWS+Basic Authentication). I could authenticate and hit my services with these Request GetItem (E-mail Message),SyncFolderItems and few other and getting the response successfully. I could parse the SyncFolderItems response to get basic info abt the Mail Items (Like Subject,To,From,HasAttachments etc.). But when i hit the GetItem request i am receiving a response but i couldnt get the Mail item Body (i.e, the Message). Is it any tutorial to do this. I am using XMLPullParser..
The response might be look like this . Plz guide me on this
I've used JWebServices for Exchange (Android version) several times. It's not free but accomplished what I needed. You should try the API to see if they get correct Body to see if your application fails or body is empty.
Thanks for ur valuable replies.. I found the data (values) that i stored from the saxparser is not complete. So only i couldnt get the html content properly in the webview.
i used the following link as reference and used the string buffer to resolve this issue.
Thx
I'm building an Android app that runs off of a rails server. At first, when I tried to post simple String data to the server, I ran into an InvalidAuthenticityToken issue, but realized that I can bypass the authentication by setting the content type to "json"
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(Constants.REST_HOST + "/add_comment");
post.addHeader("Content-Type", "application/json");
The next step was trying to get upload profile picture working. However, when I tried uploading a photo via a MultipartEntity post, setting the content type to "json" causes the following error
StandardError (Invalid JSON string):
but not setting the content type brings back the InvalidAuthenticityToken exception. What's the correct way to post an image to a rails server from a foreign Java client?
ActionController::InvalidAuthenticityToken
(ActionController::InvalidAuthenticityToken):
Based on Jesse's suggestion, I ended up using
protect_from_forgery :except => :upload_avatar_pic
to disable authenticity check, but only for a specific function, so checks for browser requests are still validated.
You can disable authenticity checking on API non-get calls from non-web clients. You can do this in a before filter
class ApiController < ApplicationController
skip_before_filter :verify_authenticity_token
def create
#or whatever
end
end
The problem solved by Jesse Wolgamott said, but the page show "You are being redirected" message when I submit the form (Update,create,show). In before that the page redirected correctly. I am using rails 2.3.8.how to resolve this?