YQL - Yahoo Geo API - yql

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.

Related

YouTube API showing 102 queries being made per request

So this is sort of weird. For every 1 request sent from my website using our YouTube API key, the developer console shows 102 queries actually being made. Here is the query format (using Python) -
search_q = '<query-string-here>'
service = build('youtube', 'v3', developerKey='<api-key>')
results = service.search().list(
part='snippet',
channelId='<specific-channel-id-to-search-through>',
type='video',
q=search_q,
).execute()
My logs show only one request being sent using this but my query count on the quotas page increases by 102.
Is there something I'm doing wrong? Or is this a bug on Google's end?
You can use the Quota Calculator to approximate the quota costs your request is using. Sure enough the search API request quota is on 100 range:

Fusion Tables API v2 still giving "Response size is larger than 10 MB. Please use media download." Error

The text here: https://developers.google.com/fusiontables/docs/v2/migration_guide implies that the 10MB limit not in effect for API v2, or that an alternative service "Media download" could be used for large responses.
The API Reference here: https://developers.google.com/fusiontables/docs/v2/reference/ does not have any information regarding the 10MB limit, or how you use "media download" to recieve your request.
How do I work around the 10MB limit for Fusion Tables API v2? I can't seem to find documentation that explains it.
To use media-download simply add the parameter alt=media to the URL
For those who use Google's API Client Libraries, the 'media download' is specified by using a specific method. For the Python library, there are two versions of the SQL query methods: sql*() and sql*_media() (and this is very likely true for the other client libraries as well).
Example usage:
# Build the googleapiclient service
FusionTables = build('fusiontables', 'v2', credentials=credentials);
query = 'select * from <table id>';
# "standard" query, returning fusiontables#sqlresponse JSON:
jsonRequest = FusionTables.query().sqlGet(sql = query);
jsonResponse = jsonRequest.execute();
# alt=media query, returning a CSV-formatted bytestring (in Python, at least):
bytestrRequest = FusionTables.query().sqlGet_media(sql = query);
byteResponse = bytestrRequest.execute();
As Kerry mentions here, media format queries that are too large to be sent as a GET request will fail (while regular format queries of the same length succeed provided the query result is less than 10 MB). In the python client, this failure appears as a HTTP 502: Bad Gateway error.
Also note that ROWIDs are currently not returned in the media response format.

Prevent JsonResult from auto-formatting Dates

I'm writing a cloud based program that utilizes UTC for date saving to the server, and convert it back on the round trip. Problem is, my instance in the cloud is autoconverting the JsonResult datetime values according to the localization settings on the browser obtaining the result.
I have gone through tons of steps to make sure the server side code on both levels is returning the proper data, and it is on all instances, and no Javascript code on my page is making the change either (even removed all my Javascript date formatting just in case), I have traced out with Firebug to determine the exact point that it changes, is when my page receives the Json Result from my JsonResult method. Like I said, I have debugged the values before being sent to the page, and they are proper, and on my response, they are modified based upon browser location....
Has anyone had a similar problem?
Value returned:Date(1341792000000) 07/08/2012 17:00
Should be: Date(1341817200000) (07/09/2012 12:00AM)
Thanks
I finally ended up getting the proper results, with many modifications to my application. I did a lot of stuff to make this happen... First, I implemented timezone.JS to get a listing of timezones that will be used within the application, and used jstz to get current timezone of browser loading the page. Next, I have to make (for mvc) an file get method that accesses the timezones to load into timezoneJS.
Next, on save of the timezone, I specified pst as the type, and then convert back to utc on roundtrip to update the interface.
On formatting of my Json date, I run the timezoneJS method and get the timezone name from jstz, and set the new date value like such:
var timezone = jstz.determine();
timezoneJS.timezone.zoneFileBasePath = '/Item/GetTz'; // get file method
var dt = new timezoneJS.Date(parseInt(jsonDate.substr(6), timezone.name())); // strips out date from json date
dt.setTimezone('America/Los_Angeles');
This allows on the cloud projects to be ran on any server, and displayed in any browser regardless of timezone, and allow the user to view and configure timezone sensitive data natively, and allow for users to see the start/end date of configurable database values.
Maybe using http://msdn.microsoft.com/en-us/library/system.datetime.specifykind.aspx
Did you try with,
date.toLocaleString()
Alternatively,
You can create a new Date object and use Date.setUTC
As the OP said:
Problem is, my instance in the cloud is autoconverting the JsonResult datetime values according to the localization settings on the browser obtaining the result.
Recently experienced something similar. Strange behavior coming from $.ajax response. Depending on the language setting of the browser, a date received in string format gets converted into whatever is set in the language setting.
For example, in Postman, Web API response is like so:
{
"id": "10057",
"d_date": "3/30/2017 3:00:00 AM",
"sum": 253.0
},
If the browser is set to english(en/en-us), response is the same as above.
If the browser is set to english-uk(en-gb), response becomes:
{
"id": "10057",
"d_date": "30/03/2017 03:00:00",
"sum": 253
}
If the browser is set to german(de), response becomes:
{
"id": "10057",
"d_date": "30.03.2017 03:00:00",
"sum": 253
}
So somehow, the browser or the $.ajax library is trying to be smart and formatting the dates automatically.
Probably, the best solution is that the Web API send the date in ISO date time format.
Another solution if you can't change the backend is to add accept-language: en in the AJAX header request. Something like so:
$.ajax({
type: 'POST',
url: '/endpoint/',
contentType: 'application/json',
data: JSON.stringify(body),
dataType: 'json',
async: false,
headers: {
'accept-language': 'en'
}
})

Getting top twitter trends by country

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.

How to get twitter server time?

So I'm trying to build a real time monitoring tool for twitter key words using tweet sharp. I'm using the search API to collect queries every 10-15 seconds. When I make the calls, I only want to collect tweets that have appeared since the pervious update.
var twitter = FluentTwitter.CreateRequest().AuthenticateAs("username", "password").Search().Query().Containing("key word").Take(1000);
var response = twitter.Request();
currentResponseDateTime= Convert.ToDateTime(response.ResponseDate);
var messages = from m in response.AsSearchResult().Statuses
where m.CreatedDate > lastUpdateDateTime
select m;
lastUpdateDateTime = currentResponseDateTime;
My issue is that the twitter server time is different from the client times by a few seconds. I looked around and tried to get the datetime I recieved the response from the Response.ResponseDate property, but it looks like that is set based on the local computer time. I.e currentResponseDateTime is a few seconds ahead of the Twitter Server time. So I end up not collecting a few of the tweets.
Does anyone know how I can get the current server time from twitter search or REST API?
Thanks
I'm not sure how you would get the local server time of the twitter service, but one approach you could take is to store the date of the most recent twitter update seen in the "lastUpdateDateTime" field. That way, you're guaranteed to get all the messages since the last one you saw, regardless of the offset of the twitter server.
var twitter = FluentTwitter.CreateRequest().AuthenticateAs("username", "password").Search().Query().Containing("key word").Take(1000);
var response = twitter.Request();
currentResponseDateTime= Convert.ToDateTime(response.ResponseDate);
var messages = from m in response.AsSearchResult().Statuses
where m.CreatedDate > lastUpdateDateTime
select m;
lastUpdateDateTime = messages.Select(m => m.CreatedDate).Max();
Another approach (and one that Twitter recommends) is to pull the Date header from their API server's response, which provides Twitter's notion of time in GMT. This assumes that you can access the server response headers, and that depends on the method you're using to access the API.
For example, hitting https://api.twitter.com/1/help/test.json
$ lynx --dump --head https://api.twitter.com/1/help/test.json
HTTP/1.0 200 OK
Date: Tue, 22 Jan 2013 13:30:36 GMT
...
Reference: how to get the twitter server time (synchronize)? on dev.twitter.com support site.
Quoting Taylor Singletary:
The current time that Twitter "thinks" it is is returned in the "Date" HTTP header of every response to an API call you make. You can also issue a simple HTTP HEAD request to GET help/test to get the header as an initial syncing step for your app.

Resources