2011-11-09 18 views
3

こんにちは私はgoogle places APIを使用するアプリケーションを開発中です。androidのGoogleプレイスAPIにアクセスする

私のアプリケーション用のAPIキーがありますが、問題はサーバーからの応答としてZERO_RESULTSです。

ここで私はDefaultHttpClientを使用してhttp接続を確立しました。誰が問題を教えてくれますか? 私はここで立ち往生してください。

public class Splash extends Activity{ 
    private String keystring=""; 
    //This is my request url 
    String requesturl="https://maps.googleapis.com/maps/api/place/search/json?" + 
     "location=17.739290150000002,83.3071201&radius=6000&" + 
     "types=hospital&sensor=false&key="; 
    private static byte[] key; 
    String signaturegot; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
      /* 
      Here I am using default http client to establish 
      the connection for the request url 
      */ 

      HttpClient client=new DefaultHttpClient(); 
      StringBuilder builder=new StringBuilder(requesturl); 
      builder.append(URLEncoder.encode(keystring)); 
      HttpPost post=new HttpPost(requesturl); 
      try { 
       HttpResponse response=client.execute(post); 
       HttpEntity entity=response.getEntity(); 
       if (entity != null) { 
        InputStream is = entity.getContent(); 
        String val = StaticUtils.convertStreamToString(is); 
       Log.e("",val); 
       } 
      } catch (ClientProtocolException e) { 
       e.printStackTrace(); 
      } catch (IOException e) { 
       e.printStackTrace(); 
      } 
    } 



Here is the response from the server 
{ 
    "html_attributions" : [], 
    "results" : [], 
    "status" : "ZERO_RESULTS" 
} 
+0

を、私はurl.Itがme.Thanksのために働いていた要求に代わり種類の名前を与えた。.. – dharan

答えて

1

によりいくつかの奇妙な理由に、インドでの位置については、代わりにtypes使用の電話番号についてはnames

https://maps.googleapis.com/maps/api/place/search/xml?&location=17.739290150000002,83.3071201&radius=6000&names=hospital&sensor=true&key=yourkeyhere

を使用しての、あなたが参照を使用して詳細情報を要求する必要がありあなたは上記のURLから入手した文字列:

https://maps.googleapis.com/maps/api/place/details/json?&reference=usethereferencestringfromtheaboveurl&sensor=true&key=yourkeyhere

出力が含まれますためHIII私は私の問題を解決し、すべての

"formatted_phone_number" : "0891 123 0101", 
     "geometry" : { 
     "location" : { 
      "lat" : 17.7060120, 
      "lng" : 83.3104410 
     } 
     }, 
+0

斐伊川リノのおかげあなたの投稿、私はあなたが言ったことと同じことをしました。しかし、私も電話番号を取得する必要があります。私はそれを行うことができますplzは助けてくれるでしょうか?ありがとう – dharan

+0

場所の詳細応答を解析する場合 JSON構造、 'formatted_phone_number'から取得できます – Reno

+0

リノお返事ありがとうございます。取得した結果からJSON解析を行いました。この番号から電話番号を取得できません。電話番号の新しいリクエストを送信する必要がありますか?あなたは電話番号を取得するためのリクエストURLを正しく作成しました。ありがとう – dharan

関連する問題