Get business type/industry from Bing Phonebook API

别等时光非礼了梦想. 提交于 2019-12-18 09:22:22

问题


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);
    });
}

回答1:


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




回答2:


I have confirmed the above answer is right, but I wanted to add that you can sort on both the relevance and the distance



来源:https://stackoverflow.com/questions/6912031/get-business-type-industry-from-bing-phonebook-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!