从Bing Phonebook API获取业务类型/行业 [英] Get business type/industry from Bing Phonebook API
问题描述
以下示例显示了我如何构建查询字符串,该字符串将返回查询字符串中定义的搜索参数的一堆地址(在本例中为Starbuck的)...我想知道是否可以使用Bing Phonebook API用于定义您正在寻找的实体类型,例如咖啡厅,加油站,软件公司等......?
The below example shows how I'm building the query string that will return a bunch of addresses for the search parameters defined in the query string (in this case, Starbuck's)...I'm wondering if it's possible to use the Bing Phonebook API to define a type of entity that you're looking for e.g. Cafe, Gas Station, Software Company, etc...?
function Search(position) {
// note a bunch of this code uses the example code from
// Microsoft for the Phonebook API
var requestStr = "http://api.bing.net/json.aspx?"
// Common request fields (required)
+ "AppId=" + _appId
+ "&Query=starbucks"
+ "&Sources=Phonebook"
// Common request fields (optional)
+ "&Version=2.2"
+ "&Market=en-us"
+ "&UILanguage=en"
+ "&Latitude=" + position.coords.latitude
+ "&Longitude=" + position.coords.longitude
+ "&Radius=100.0"
+ "&Options=EnableHighlighting"
// Phonebook-specific request fields (optional)
// Phonebook.Count max val is 25
+ "&Phonebook.Count=25"
+ "&Phonebook.Offset=0"
// YP = Commercial Entity, WP = Residential
+ "&Phonebook.FileType=YP"
+ "&Phonebook.SortBy=Distance"
// JSON-specific request fields (optional)
+ "&JsonType=callback"
+ "&JsonCallback=?";
$.getJSON(requestStr, function (data) {
SearchCompleted(data);
});
}
推荐答案
我不是100%当然,但我不认为API有类别选项。但是,我认为如果您只是在搜索查询中包含该类别,您将获得更好的结果。它本质上是一个标准的谷歌(在这种情况下,显然是bing)搜索,所以你可以让它搜索任意数量的术语。
I'm not 100% sure, but I don't think the API has a category option. However, I think if you simply included the category in the search query, you would get better results. It's essentially a standard google(bing in this case, obviously) search so you can have it search for any number of terms.
所以找到星巴克并定义它应该是咖啡:
So to find starbucks and define that it should be coffee:
"&Query=starbucks coffee"
另一个提示:除非距离非常重要,否则请使用:
Another tip: Unless distance is absolutely important, use:
SortBy=Relevance
这似乎有助于减少愚蠢的结果
This seems to help reduce dumb results
这篇关于从Bing Phonebook API获取业务类型/行业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!