getting link of an API : openweathermap.com - android

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

Related

Getting text on jsoup?

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

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).

What is Authorization callback URL? Android

I need to use Imgur to upload images online using android eclipse. i created an account and was trying to register my application to get the client id and client secret. i reached here https://api.imgur.com/oauth2/addclient
I entered my Application Name as : com.nyp.assignment (is this just a name to it or we need to follow our package name? pls advise as well)
when i get to the callback url , i have no idea what to write for it. i've refered to here at https://api.imgur.com/oauth2 but still dont get it.
can someone list an example of a callback URL for Android? (Eclipse)

Ebay API Filter not working

I'm trying to get all the products listed by two companies by using the eBay api on my android phone. I do this by using the item filter but when I run this it will return product from all companies not from just from the companies I have stated. Why is this? Below is the http I send (MyAppIid is my actually Id and Seller1Name and Seller2Name are the companies I select)
http://open.api.ebay.com/finding?callname=findItemsAdvanced&responseencoding=JSON&appid=MyAppID&siteid=3&version=713&QueryKeywords=android&GLOBAL-ID=EBAY-UK%203g&itemFilter(0).name=Seller&itemFilter(0).value(0)=Seller1Namet&itemFilter(0).value(1)=Seller2Name
It seems that you try to use a mix of Shopping and Finding API. It's interesting that it works at all without an API error. In any case you should use the eBay Finding API for your purpose. Here is an example how the URL may look like:
http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.13.0&SECURITY-APPNAME=YOUR_APP_ID_HERE&GLOBAL-ID=EBAY-GB&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findItemsAdvanced&REST-PAYLOAD&itemFilter(0).name=Seller&itemFilter(0).value(0)=doria-store&itemFilter(0).value(1)=universalgadgets01&keywords=android&outputSelector(0)=SellerInfo
I've created an example in our Live API Playground. You can adapt the call to your needs and execute it to see the response directly in the response area. When you're done, click on "Retrieve JS code" and you will get ready-to-use JS code including the URL for the call with all its parameters you've configured.

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