Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
// Get woeid by lati/long
HttpGet hg = new HttpGet(
"http://where.yahooapis.com/geocode?location=" + latlon + "&flags=J&gflags=R)");
HttpClient hc = new DefaultHttpClient();
HttpResponse weatherHR = hc.execute(hg);
if (weatherHR.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
if (DEBUG)
Utils.log("", "Location != HttpStatus.SC_OK");
return null;
}
I used this API and it work ok before, but It return a error since today, the HttpStatus.SC_OK is not OK. Has this API been closed? Thanks.
Yahoo has moved to paid service called BOSS but they do offer a non-commercial service:
Non-Commercial usage of Yahoo Geo API's
Yahoo! continues to fully support developer applications built on top of Placefinder and PlaceSpotter in non-commercial settings. Both services are available to you via YQL and rate limited to 2000 queries per table. Learn more about using the Placefinder and Placespotter YQL tables.
Using Placefinder you can reverse lookup a latitude and longitude:
http://developer.yahoo.com/yql/console/?q=select%20*%20from%20geo.placefinder%20where%20text%3D%2237.416275%2C-122.025092%22%20and%20gflags%3D%22R%22
which can be converted into a json request:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%2237.416275%2C-122.025092%22%20and%20gflags%3D%22R%22&format=json
Yes, it's closed, give a look here:
http://soup.metwit.com/post/47181933854/an-alternative-to-yahoo-weather-api
A city can also be used as location as follows:
select *
from weather.forecast
where woeid in (
select woeid
from geo.places(1)
where text="frankfurt"
) and u="c"
Where "frankfurt" can be replaced with any location of choice.
To get the Yahoo Weather WOEID by latitude and longitude, you can use this
https://query.yahooapis.com/v1/public/yql?q=select%20woeid%20from%20geo.places%20where%20text%3D%22(20,34)%22%20limit%201&diagnostics=false&format=json
And you will receive a response like the following:
{
"query":{
"count":1,
"created":"2017-03-17T20:34:50Z",
"lang":"es-AR",
"results":{
"place":{
"woeid":"1435509"
}
}
}
}
If still someone need answear. You have basic URL:
https://query.yahooapis.com/v1/public/yql?q=
Now you have to make correct YQL statement (replace city with your city name) e.x.
select * from geo.places where text="city"
Now you have to encode to URI. You can use javascript method: encodeURIComponent().
Then you have to merge basicURL and encoded YQL statement and
&format=json
So example of the whole link for San Francisco will be:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text%3D%22san%20francisco%2C%20ca%22&format=json
Now from response you have to get WOEID number. You can get it by:
query>results>place>[0]>woeid
So in Javascript it will be something like:
const woeidNumber = responseObject['query']['results']['place'][0]['woeid'];
Related
I'm currently using Consolibyte's PHP QB classes to interface with the QB api.
I've been successfully creating and updating Vendor's in QB for a while. However, we have a new requirement to use the API to store vendor's tax information.
I've tried to lookup the correct syntax to set these, but have been unsuccessful thus far.
My most recent attempt was:
$Vendor->setVendorTaxIdent($provider->taxId);
$Vendor->setIsVendorEligibleFor1099(true);
The rest of the information set gets updated properly, and the return from
$result = $VendorService->update($this->context, $this->realm, $provider->vendorId, $Vendor);
seems to indicate success.
Please let me know if you need anymore context. Thanks!
Have you referred to the documentation?
https://developer.intuit.com/docs/api/accounting/Vendor
The documentation indicates:
TaxIdentifier: String, max 20 characters
Vendor1099: Boolean
The geters and seters exactly mirror the documented fields. So unsurprisingly, you'll have these methods:
$Vendor->setTaxIdentifier($string);
$string = $Vendor->getTaxIdentifier();
And:
$Vendor->setVendor1099($boolean);
$boolean = $Vendor->getVendor1099();
If you continue to have trouble, make sure you post the XML request you're sending to QuickBooks. You can get this by doing:
print($VendorService->lastRequest());
print($VendorService->lastResponse());
The following query using the Yahoo API started to return a result of 'null' since yesterday. (in fact all my queries against the geo.placefinder) return result: null.
Is anyone aware of an update / work that yahoo is doing? I have tried using their developer console but that returns null result as well. This query is a crucial part of my application that now is dysfunctional.
https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22sfo%22&format=json
I have encountered the same problem, as I understand the placefinder was meant to be shutdown on Nov 17, 2012 and we were meant to use the paid service Boss Geo.
see:
https://developer.yahoo.com/blogs/ydn/introducing-boss-geo-next-chapter-boss-53654.html#more-id2
YQL tables for development
If you are looking to continue experimenting with the standalone PlaceFinder and PlaceMaker services, we are excited to continue supporting you through our YQL tables. These tables will be limited to 2,000 queries per day and are meant for non-commercial usage. We intend to shut down the current free versions of PlaceFinder and PlaceMaker on November 17, 2012.
Workaround:
For a direct replace of the current url you can use a combination or YQL and gws2.maps.yahoo.com. For example, to get the location of the random co-ordinates below the url will be the following:
var url = https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%20%3D%20%27http%3A%2F%2Fgws2.maps.yahoo.com%2Ffindlocation%3Fpf%3D1%26locale%3Den_US%26offset%3D15%26flags%3D%26gflags%3DR%26q%3D52.01%2C4.82%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
to execute it with ajax it would be something like the following:
$.ajax(
{
url: url,
type: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: getWeatherForLocation,
error: appErrorHandler
});
This is the same as the post at Yahoo YQL query with gFlags returns nothing
Several solutions to this are posted on that thread.
I am trying to do a simple Salesforce-Asana integration. I have many functions working, but I am having trouble with adding a tag to a workspace. Since I can't find documentation on the addTag method, I'm sort of guessing at what is required.
If I post the following JSON to https://app.asana.com/api/1.0/workspaces/WORKSPACEID/tasks:
{"data":{"name":"MyTagName","notes":"Test Notes"}}
The tag gets created in Asana, but with blank notes and name fields. If I try to get a bit more fancy and post:
{"data":{"name":"MyTagName","notes":"Test Notes","followers":[{"id":"MY_USER_ID"}]}}
I receive:
{"errors":[{"message":"Invalid field: {\"data\":{\"name\":\"MyTagName\",\"notes\":\"Test Notes\",\"followers\":[{\"id\":\"MY_USER_ID\"}]}}"}]}
I'm thinking the backslashes may mean that my request is being modified by the post, though debug output shows a properly formatted json string before the post.
Sample Code:
JSONGenerator jsongen = JSON.createGenerator(false);
jsongen.writeStartObject();
jsongen.writeFieldName('data');
jsongen.writeStartObject();
jsongen.writeStringField('name', 'MyTagName');
jsongen.writeStringField('notes', 'Test Notes');
jsongen.writeFieldName('followers');
jsongen.writeStartArray();
jsongen.writeStartObject();
jsongen.writeStringField('id', 'MY_USER_ID');
jsongen.writeEndObject();
jsongen.writeEndArray();
jsongen.writeEndObject();
jsongen.writeEndObject();
String requestbody = jsongen.getAsString();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://app.asana.com/api/1.0/workspaces/WORKSPACEID/tags');
req.setMethod('POST');
//===Auth header created here - working fine===
req.setBody(requestbody);
Http http = new Http();
HTTPResponse res = http.send(req);
return res.getBody();
Any help appreciated. I am inexperienced using JSON as well as the Asana API.
The problem was that I was posting to the wrong endpoint. Instead of workspaces/workspaceid/tags, I should have been using /tags and including workspaceid in the body of the request.
Aha, so you can add tags and even set followers despite the API not mentioning that you can or claiming that followers are read-only.
So to sum up for anyone else interested: POSTing to the endpoint https://app.asana.com/api/1.0/tags you can create a tag like this:
{ "data" : { "workspace": 1234567, "name" : "newtagname", "followers": [45678, 6789] } }
where 1234567 is your workspace ID and 45678 and 6789 are your new followers.
Since you posted this question, Asana's API and developer has introduced Tags. You documentation lays out the answer to your question pretty clearly:
https://asana.com/developers/api-reference/tags
I'm a bit confused by your question. Your ask "how to add a tag" but the first half of your question talks about adding a task. The problem with what you describe there is that you are trying to set a task's followers but the followers field is currently read-only according to Asana's API documentation. That is why you are getting an error. You can not set followers with the API right now.
The second part of your question - with the sample code - does look like you are trying to add a tag. However, right now the Asana API does not support this (at least according to the API documentation). You can update an existing tag but you can't add one.
So, to sum up: at this time the API does not allow you to add followers to a task or to create new tags.
I know how to get trends using API, but i want it by country and top 10.
How can I ? Is that possible?
Tried this one but not working
http://api.twitter.com/1/trends/current.json?count=50
Note that Twitter API v1 is no longer functional. Read announcement
So you should use Twitter API 1.1.
REST method is this: GET trends/place
https://dev.twitter.com/docs/api/1.1/get/trends/place
You should authenticate with access tokens to reach this data.
Yes, you can.
First, figure out which countries you want to get data for.
Calling
https://dev.twitter.com/docs/api/1/get/trends/available
Will give you a list of all the countries Twitter has trends for.
Suppose you want the trends for the UK. The above tells us that the WOEID is 23424975.
To get the top ten trends for the UK, call
https://api.twitter.com/1/trends/23424975.json
you need to figure out the woeids first use this tool here http://sigizmund.info/woeidinfo/ and then it becomes as easy as a simple function
function get_trends($woeid){
return json_decode(file_get_contents("http://api.twitter.com/1/trends/".$woeid.".json?exclude=hashtags", true), false);
}
Here you go, I wrote a simple sample script for you. Check It Out Here Twitter Trends Getter
Hope it helps!
I'm a 'bit' late to the party on this one but you can use:
npm i twit --save
then,
const Twit = require('twit');
const config = require('./config');
const T = new Twit(config);
const params = {
id: '23424829',
id: '23424975',
id: '23424977'
// count: 3
};
T.get('trends/place', params, gotData, limit);
function gotData(err, data, response) {
var tweets = data;
console.log(JSON.stringify(tweets, undefined, 2));
}
You have to Complete Authentication using Api Key to Fetch Results in JSON.
Another Thing Keep in Mind Twitter Api is Limited.
If you are Making Website for Top Twitter Trends then Visit this Url https://twitter-trends.vlivetricks.com/, Right Click >> Copy Source Code and Replace only Trends Name using Your Json Variable.
I want to validate that zip code entered by user is valid or not.
for example user entered 009876654 and it is not valid then an error message should be given.
I know i can do it using javascript regulr expression or using ajax-zip-code-database
But i don't want any of the above. i need some plugin sort of thing which send request to some online application to check wheather it is valid or not.I want this because i don't want to take care if in future there is change in the zip-codes or new zip-codes get added.
P.S. :- I don't want to use javascript or using ajax-zip-code-database
There is a web service at webservicex that can give you XML results from a GET or even a POST call. I've never used it but it seems to be what you're looking for.
Non-existent zip codes return an empty data set
wget http://www.webservicex.net/uszip.asm /GetInfoByZIP?USZip=60001
<?xml version="1.0" encoding="utf-8"?>
<NewDataSet>
<Table>
<CITY>Alden</CITY>
<STATE>IL</STATE>
<ZIP>60001</ZIP>
<AREA_CODE>815</AREA_CODE>
<TIME_ZONE>C</TIME_ZONE>
</Table>
</NewDataSet>
Assuming your application is commercially compatible with their terms of use, I'm wondering if you can use Google's gecoder service to lookup a zip/postal code and then to check the results to see if it exists. I would assume if you get back a postcode and a sane lat, lng pair you could conclude the zipcode is real.
The code below (admittedly using the now deprecated V2 API shows one approach for a US-centric search). The advantage is that it's the end-user and Google compute resources and bandwidth that are used to do the validation.
I don't know if this a bit heavy for your purposes although I've found Google's gecoder to be blindingly fast.
gecoder = new GClientGeocoder();
geocoder.getLocations(zipcode, function(response) {
if (response && response.Status.code === 200) {
var places = response.Placemark;
for (var p in places) {
if (places[p].AddressDetails.Country.CountryNameCode === 'US') {
// lat => places[p].Point.coordinates[1],
// lng => places[p].Point.coordinates[0],
// zip => places[p].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber
}
}
}
});