Ibm mobilefirst IBM Worklight-适配器过程响应返回;“零结果”;来自Google Places

Ibm mobilefirst IBM Worklight-适配器过程响应返回;“零结果”;来自Google Places,ibm-mobilefirst,google-places-api,worklight-adapters,Ibm Mobilefirst,Google Places Api,Worklight Adapters,当我使用印度纬度和经度调用HTTP适配器来搜索任何服务(如食品、商场等)时,我得到的状态是“零结果” 以下是我的适配器实现: function getGooglePlaces(location,name) { var input = { method : 'get', returnedContentType : 'json', path : 'maps/api/place/search/json', headers: {

当我使用印度纬度和经度调用HTTP适配器来搜索任何服务(如食品、商场等)时,我得到的状态是“零结果”

以下是我的适配器实现:

 function getGooglePlaces(location,name) {

    var input = {
        method : 'get',
        returnedContentType : 'json',
        path : 'maps/api/place/search/json',
        headers: {
            Host: 'maps.googleapis.com'
        },
        parameters : {
            'key'       :   My Key,
            'location'  :  location,
            'radius'    :   '10000',
            'sensor'    :   'false',
            'name'      :  name 
        }
    };

    var response = WL.Server.invokeHttp(input); 
    return response;

}
}

印度坐标的JSON响应。
结果是搜索位置的数组

{
 "html_attributions": [
  ],
 "isSuccessful": true,
 "responseHeaders": {
  "Alternate-Protocol": "443:quic",
  "Cache-Control": "public, max-age=300",
  "Content-Type": "application\/json; charset=UTF-8",
  "Date": "Wed, 12 Feb 2014 15:06:33 GMT",
  "Expires": "Wed, 12 Feb 2014 15:11:33 GMT",
  "Server": "mafe",
  "Transfer-Encoding": "chunked",
  "Vary": "Accept-Language",
  "X-Frame-Options": "SAMEORIGIN",
  "X-XSS-Protection": "1; mode=block"
   },
  "responseTime": 609,
  "results": [
   ],
   "status": "ZERO_RESULTS",
   "statusCode": 200,
   "statusReason": "OK",
   "totalTime": 609
   }

我使用了以下命令,并使用Worklight适配器获得了有效响应

  • 请注意,我将
    name
    location
    作为parameters对象的一部分传递,与您不同(只是为了简化)
  • 我为“restaurant”添加了一个
    type
    参数
  • 我增加了
    半径
通过以上步骤,我得到了结果。
在我看来,这是一个调整请求参数的问题。这里没有与Worklight适配器相关的内容

GooglePlaces impl.js

function getPlaces() {
    var input = {
            method : 'get',
            returnedContentType : 'json',
            path : 'maps/api/place/search/json',
            headers: {
                Host: 'maps.googleapis.com'
            },
            parameters : {
                'key'       : 'make-sure-to-place-here-your-SERVER-KEY-generated-by-Google-GCM-console',
                'location'  : '27.173033, 78.042133',
                'radius'    : '30000',
                'sensor'    : 'false',
                'name'      : 'Taj Mahal',
                'type'      : 'restaurant',
            }
        };

        var response = WL.Server.invokeHttp(input);
        return response;
}
程序响应

{
   "html_attributions": [
   ],
   "isSuccessful": true,
   "responseHeaders": {
      "Alternate-Protocol": "443:quic",
      "Cache-Control": "public, max-age=300",
      "Content-Type": "application\/json; charset=UTF-8",
      "Date": "Fri, 14 Mar 2014 05:45:41 GMT",
      "Expires": "Fri, 14 Mar 2014 05:50:41 GMT",
      "Server": "mafe",
      "Transfer-Encoding": "chunked",
      "Vary": "Accept-Language",
      "X-Frame-Options": "SAMEORIGIN",
      "X-XSS-Protection": "1; mode=block"
   },
   "responseTime": 662,
   "results": [
      {
         "geometry": {
            "location": {
               "lat": 27.175015,
               "lng": 78.042155
            }
         },
         "icon": "http:\/\/maps.gstatic.com\/mapfiles\/place_api\/icons\/generic_business-71.png",
         "id": "dcc9586b99ab0f0471fccecbe2dbb40fdc1fc2b5",
         "name": "Taj Mahal",
         "photos": [
            {
               "height": 853,
               "html_attributions": [
               ],
               "photo_reference": "CnRnAAAAojrNNKpH2yqjmiph_kNBxiT5DaK_g3N05YtE_mPP5tBrYD8XjyAAz_xEvWAJymfGOeeOTlVgzFUxUeOMQspvoPGogDQyWomDeZsNP7XEW3JsmzmYakDk_vyJBwajiamhluypx6rCDqDCnBWb6JnCLBIQRuBibftSN9xruu2eeZEm5xoUksG5kyFbtZULWpZceNvNhyl72tQ",
               "width": 1280
            }
         ],
         "rating": 4.6,
         "reference": "CnRrAAAA8n6I_Dnlm9UzwTiaTntjcxR-FysL5Ya26Fdcsdb48XOIxiJDGdd3AiK6iUUti41d1BQ1XnBfZoVMKWZ5QOyVZAW8QyH-xqSY8eaQXuxH0atjzXtuaplht-ww76JtbxQLkJ4SUtFrmrs7ZjmZn-_RhBIQmYTB0_yGd_4hm2bHoIKt5xoULaBq-FsZo51jFdxLV377nHM0cCI",
         "types": [
            "establishment"
         ],
         "vicinity": "Agra"
      },
     ...
     ...
     "status": "OK",
       "statusCode": 200,
       "statusReason": "OK",
       "totalTime": 1088
    }

好吧,零搜索结果意味着谷歌没有找到你指定的半径。在不使用适配器或Worklight的情况下,您是否在半径和纬度/经度方面找到了所需的内容?是的,我没有使用Worklight,但在相同的经纬度上得到了一些结果,我在Worklight Adapter中使用了这些结果谢谢您的回答@idan。这对我很有帮助