I'm developing an app and one of the features I want to include is being able to get the users location and convert it to a WOEID value and then get the weather data from the Yahoo Weather RSS feed. Here's the documentation that states the requirement for the WOEID value:
http://developer.yahoo.com/weather/
You can get the WOEID by using the Yahoo! PlaceFinder API. First you need to request an API key, then you can send your request like this:
http://where.yahooapis.com/geocode?q=[search query]&appid=[yourappidhere]
You will get this as a response:
<ResultSet xmlns:ns1="http://www.yahooapis.com/v1/base.rng" version="2.0" xml:lang="en-US">
<Error>0</Error>
<ErrorMessage>No error</ErrorMessage>
<Locale>en-US</Locale>
<Found>1</Found>
<Quality>85</Quality>
<Result>
<quality>85</quality>
<latitude>38.898708</latitude>
<longitude>-77.036369</longitude>
<offsetlat>38.89719</offsetlat>
<offsetlon>-77.036537</offsetlon>
<radius>400</radius>
<name/>
<line1>1600 Pennsylvania Ave NW</line1>
<line2>Washington, DC 20500-0005</line2>
<line3/>
<line4>United States</line4>
<house>1600</house>
<street>Pennsylvania Ave NW</street>
<xstreet/>
<unittype/>
<unit/>
<postal>20500-0005</postal>
<neighborhood/>
<city>Washington</city>
<county>District of Columbia</county>
<state>District of Columbia</state>
<country>United States</country>
<countrycode>US</countrycode>
<statecode>DC</statecode>
<countycode>DC</countycode>
<uzip>20500</uzip>
<hash>4216F67AA1A143E9</hash>
<woeid>12766118</woeid> // This is what you need
<woetype>11</woetype>
</Result>
</ResultSet>
You can parse the response for the <woeid> tag.
Edit:
If you have an EditText and you want to get the weather based on the city you get from his input then you'll have to do this:
String searchQuery = Uri.encode(myEditText.getText().toString());
Now you'll have your search query. So e.g if the user types in:
Hamburg Germany
then this will convert it to:
Hamburg_Germany
Related
Can any one help me to get solution for the api changing based on the email id(account details )
ex:
/api/getRooms/test#gmail.com
(last name is changing) for other accounts .
Put all the email ids in the csv with header (Header Name:- Email).
Then, use "CSV Data Set Config" to provide them as inputs to your request. Pass the header as variable to the api like /api/getRooms/${Email}.
I am new to Firebase Database, I am making an android app in which the structure of the data is like this :
{
posts={
-Ks4AoL7F-oKtwd3M8Ao={
address=Address of mine,
title=Title ,
subcategory=E-waste, category=Garbage,
time=21-08-2017 07:54 p.m.,
mobileNumber=some mobile number,
comment=hhdhdehsbsbhs,
statusText=Pending,
imagePath=https://firebasestorage.googleapis.com/v0/b/path-to-image
},...
}
So in this structure i want to query the posts on the basis of the mobile number i.e., if the mobile number matches than the current post will be retrieved else skip this post and check for next post and so on...
you can get all the list of data from post object with the help of simple queries which you can find in documentation part of firebase, where you can check for each object's mobile no, accordingly apply the conditions to keep or discard the object.
for more info please look into the link:-
sample to retrieve the data from firebase
You can refer this post and
This
I want change JSON received data from Forecast api to custom units. In API's doc they're wrote i should change query parameters to get this done.
the API call look like this:
https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE
i wonder how i could send option for changing units. this is what they're wrote:
Options
The API request may optionally be modified through the use of query parameters. It will respond to the following:
units=[setting]: Return the API response in units other than the default Imperial units.
Thanks
As the api states that optional parameters can be added as query parameters to the url , your url should look like
https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE?units=VALUE
VALUE is the the type of unit you want to select
Some options are
us
si
ca
uk2
auto
I'am using Twitter4j API to collect tweets from india. I am applying filter to collect tweets having specific keywords only, but i'am getting all tweets from india region, not having that specific keywords. my code is
FilterQuery filter = new FilterQuery();
String keyword[]= {"flu"};
double [][]location ={{68.1,8.06},{97.41,37.10}};
filter.track(keyword);
filter.locations(location);
twitterstream.addListener(listener);
twitterstream.filter(filter);
how can get tweets from India having "flu" as a part of tweet text.
This is so because twitter filter parameters together do not apply as AND but OR.
Check more here - https://dev.twitter.com/streaming/overview/request-parameters
The twitter API documentation also says so -
Bounding boxes do not act as filters for other filter parameters. For example track=twitter&locations=-122.75,36.8,-121.75,37.8 would match any tweets containing the term Twitter (even non-geo tweets) OR coming from the San Francisco area.
Hope this helps.
I'm using the Yahoo Finance Streaming API to get stock quotes, I wanted to save these into a DB table for historical reference.
I'm looking for something which can easily parse various strings which have a format that varies like the examples below:
<script>try{parent.yfs_mktmcb({"unixtime":1310957222});}catch(e){}</script>
<script>try{parent.yfs_u1f({"ASX.AX":{c10:"-0.06"}});}catch(e){}</script>
<script>try{parent.yfs_u1f({"AWC.AX":{l10:"2.16",c10:"+0.01",p20:"+0.47"}});}catch(e){}</script>
<script>try{parent.yfs_u1f({"ALZ.AX":{l10:"2.6900",c10:"-0.1200",p20:"-4.27"}});}catch(e){}</script>
I want to parse these strings to a MySQL database and I was thinking the easiest way will be using Java to do this parsing. Basically these entries are line by line in a text file. I want to extract the time, the stock code, the price and the change values in a simple table.
The table looks like StockCode | Date | Time | Price | ChangeDol | ChangePer
Are there any tools or frameworks which would make this process easy?
Thanks!
I don't how you get your quote, but if you could use YQL, any XML parser would do:
YQL
<quote symbol="YHOO">
<Ask>14.76</Ask>
<AverageDailyVolume>28463800</AverageDailyVolume>
<Bid>14.51</Bid>
<AskRealtime>14.76</AskRealtime>
<BidRealtime>14.51</BidRealtime>
<BookValue>9.826</BookValue>
<Change_PercentChange>0.00 - 0.00%</Change_PercentChange>
....
</quote>
List of XML Parsers for Java
You could have a look there
http://www.wikijava.org/wiki/Downloading_stock_market_quotes_from_Yahoo!_finance
They get finencial data as csv from yahoo.