Get business type/industry from Bing Phonebook API

2019-01-29 00:51发布

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

2条回答
我想做一个坏孩纸
2楼-- · 2019-01-29 01:33

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

查看更多
我只想做你的唯一
3楼-- · 2019-01-29 01:35

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

查看更多
登录 后发表回答