Getting text on jsoup? - android

I recently was referred to jsoup and I am trying to retrieve a string from a Google Script API link that feeds me a single string. However, I am unable to retrieve it. When I do
val ipadd: String = doc.body()
I do not seem to see my string inside. I have also tried
val ipadd: String = doc.getElementsContainingText("L1").toString()
but it didn't work either. If anyone could provide some help, that would be great. I have put the url for the Google Script API below. Thanks.
https://script.google.com/macros/s/AKfycbyjRIRl2ca_pnfz8XgccjDlaRPUNz6KY_WcyPZAROsy9EZkD35F/exec?command=GetLock1IPAddress

You are trying to get a value through Google Service. Since you are asked to "authenticate", you cannot get that value because you cannot access the corresponding value. When I test it with Jsoup individually, you will encounter a related error.
Sample questions are shared to discuss the "auth" process.
Sample 1
Sample 2
Sample Code Google Service Auth

Related

getting link of an API : openweathermap.com

I am a beginner, just made few simple apps in android sdk.
I learnt about extracting data of websites which have JSON format. i tried to extract data of "openweathermap.com" for the city London by API calls in execute method of AsynkTask, and my app got crashed by getting null result from web.
Though it is giving desired result when i am passing other links like http://openweathermap.org/current to get full web Contents.
here is my code, its working.
DownloadContentTask task = new DownloadContentTask();
task.execute("http://openweathermap.org/current");
its not working:
DownloadContentTask task = new DownloadContentTask();
task.execute("api.openweathermap.org/data/2.5/weather?q=London");
when I googled, i got
"You can call by city name or city name and country code. API responds with a list of results that match a searching word.
Examples of API calls:
http://api.openweathermap.org/data/2.5/weather?q=London"
can someone please help to get me an appropriate way for API calls. I will be Thankful.
Read this API Error.You are fetching second error 401.So create an account here Create account.After sign in the account find API Keys.And then use like following :
http://api.openweathermap.org/data/2.5/weather?q=London&appid=Your_API_Key

Google Places API does not returns photos via photoreference in android

I am using Google places API to get the details of particular restaurant.
Now, I wish to display the image of the restaurant in my android app .
For that, I referred this .
However, the below link which is required to get an error gives me a 500 error and when I use http:// in the link instead of https:// , it gives an image which says you have exceeded the API limit.
I am using Glenter link description hereide to display these images. I dont think there's any issue with the Glide . The url generated does not gives any output.
Below is the code :
String url = mPlaces.getIcon();
String photoreference = mPlaces.getPhotoreference();
String restaurantpic = "http://maps.googleapis.com/maps/api/place/photo?" +
"maxwidth=400" +
"&photoreference=" +photoreference +
"&key="+API_KEY;
Log.d("Loading restaurantpic" , restaurantpic);
Glide
.with(mContext)
.load(restaurantpic)
.centerCrop()
// .placeholder(R.drawable.loading_spinner)
//.crossFade()
.into(mImageViewIcon);
This is an example of restaurantpic URL with https protocol which gives 500 error. The same with HTTP protocol gives below attached image(Which is for quota filled).
So guys, It was my silly mistake to use "referenece" field from the JSON data instead of "photo-reference" field .
The issue was resolved .
In case anyone else is having some trouble with this:
If you are trying to use the Web Service API key on Android it will not work correctly if you are also trying to restrict that API key to only certain Android Apps (by package name/fingerprint)
See here:
https://developers.google.com/places/web-service/get-api-key#get_an_api_key
Note: The Google Places API Web Service does not work with an Android or iOS restricted API key.

Android app to get .aspx form response

I'm new to Android development. I'm working on an app for use at work - I'm an EMT. I was hoping to use the state's registry as a means of authenticating the user as an active provider. https://ems.health.state.pa.us/emsreg/activepractitioners.aspx
I know nothing of asp, except that I should be able to pass some input through the URL with ?name=value. But when I inspect the element of the last name field...
input name="_ctl0:_ctl0:SessionLinkBar:Content:tbxLName" type="text"
id="_ctl0__ctl0_SessionLinkBar_Content_tbxLName"
I can't use this. Honestly not even sure what I'm looking at here. Is ":" a container?
Ultimately I'd like to take the user input on 2 edit texts (last name & certification #), click a button to POST them to the activepractitioners.aspx, and either get the whole response and pare down for what I need (Status Active, which I've yet to find labeled on the site) or verify the response then query its label.
I've tried a few of the methods here and I keep crashing the emulator. Also I'd rather not see all the strikethroughs in Android Studio from deprecated methods. I welcome all help, but please remember I'm a n00b - take it slow for me. Thanks!
UPDATE:
I've gotten some results using JSoup. I get to a landing page that should contain just one result (the certification # is unique) and a link. The format of the link is as follows:
<a id="_ctl0__ctl0_SessionLinkBar_Content_dgSearchResults__ctl2_lnk" href="javascript:__doPostBack('_ctl0$_ctl0$SessionLinkBar$Content$dgSearchResults$_ctl2$lnk','')">
It uses javascript to invoke "doPostBack." Any idea on how to automate this too? As it is I can parse the response to a document and scrape the table for the word "active." But I'd like a bit of fool-proofing. Thanks in advance!
Since you are new to Android dev, I suggest you to spend some time having a look to Google Android Volley APIs.
It allows you to easily set up GET and POST requests (and works great).

CreateWalletObjectsRequest is missing from com.google.android.gms.wallet API

As per the given link: https://developers.google.com/wallet/objects/savetowalletnative
I am trying to run the sample application, but in this below method, I am not able to find CreateWalletObjectsRequest. It says:
"CreateWalletObjectsRequest cannot be resolved to a type"
public void saveToWallet(View view){
LoyaltyWalletObject wob = generateObject();
CreateWalletObjectsRequest request = new CreateWalletObjectsRequest(wob);
Wallet.createWalletObjects(googleApiClient, request, SAVE_TO_WALLET);
}
Google hasn't opened Save to Wallet api for everyone yet. We had to get a special Google Play Services AAR directly from Google, along with a lot of help from a Googler to get it functioning (the sample is out of date).
As of now, you'll need to work with your Google contact to get the second-party library to integrate Android Pay. Once you get the aar file, you can import it into your project and add it as a dependency.
Now, the 'createWalletObjects' method call in your question has shifted in its location and signature; its now as follows:
Wallet.WalletObjects.createWalletObjects(googleApiClient, request, SAVE_TO_WALLET);
The SAVE_TO_WALLET is the integer request code that you'll identify the request in your onActivityResult(). Creating the request as such is described in the "Create an object" section of https://developers.google.com/save-to-android-pay/guides/android/add-button-to-your-app

Graph API: Same request with different album ID returns empty JSONObject?

I am using following code in my android app in a for loop of albumIDs to make requests for getting specific photo object information:
AsyncFacebookRunnerObj.request(currentAlbumID +"/photos?fields=id,name,source,created_time", new myRequestListner, refString);
I know the albumIDs of my friend's profile which I can see from my facebook profile. Though I can see all the albums I want to retrieve (they are public), but calls to this function still returns empty for some of albumIDs while for others it works perfectly fine.
When I access the albums using Graph API explorer i can retrieve all photos from all albums. Access_token in this case is different but I guess it is supposed to be different because in my case I am accessing it from app.
Please let me know what can be wrong?
Thanks.
I ran into a similar issue with the FB JS SDK. Check that your json parser is parsing the album id as a string instead of a long/double (probably only a mixed-type language issue, but worth investigating).

Categories

Resources