我正在使用google autocomplete地方api。Google Place API無法在Android上使用密鑰
https://maps.googleapis.com/maps/api/place/autocomplete/json?key= 「我的Android按鍵」 &輸入=毫克%20Ro &成分=國家:
從控制檯產生我的重點是Android的關鍵
我在谷歌API控制檯啓用API是
Google Places API Web Service
Google Places API for Android
Google Maps Android API
和SHA-1指紋是debug-keystore。 現在的擊球,我得到的輸出此鏈接是
{"error_message":"This IP, site or mobile application is not authorized to use this API key. Request received from IP address 122.177.199.201, with empty referer","predictions":[],"status":"REQUEST_DENIED"}
雖然在服務器密鑰的情況下,我得到適當的響應
{"predictions":[{"description":"MG Road Metro Station","id":"9db78081a8f0e59874d51baff0df2c007e8c8dde","matched_substrings":[{"length":2,"offset":0}],"place_id":"ChIJY8G_aiIZDTkRohS7EKRePsw","reference":"CjQkAAAAj-nav4S-WWDQfmK7D5V_uc6XT8s5wZzsKNLQMHA7ucgRD_AGu5uIoxvWlxtpJaAiEhDOj61RTKbD9lK28Seovch6GhSPoMA7WPxS6v8ApRf_q03TtnzzrQ","terms":[{"offset":0,"value":"MG Road Metro Station"}],"types":["transit_station","point_of_interest","establishment","geocode"]},{"description":"M G Road Metro Station, Mehrauli-Gurgaon Road, Sector 28, Gurgaon, Haryana, India","id":"041408b314da313beac2e2016c697a9aba451be8","matched_substrings":[{"length":22,"offset":0}],"place_id":"ChIJATH6EiIZDTkR-aEggPmaDrU","reference":"CmRgAAAAEMJLJnkGwPSnN5BmE7_IU_UTEAxRT83T2IuHGKja7PouwUxH6j6gVzPlWiSi-yPgYH1vEUs_wiLMME2QbSkOBACPdtQmPdjQ5q-BlLxL3d81UOvaD8-jtvgrKOLLF_dPEhCRDuiBXJ90DQMY7ioJsQxnGhSFULVBF754FuwF2LFwzWTvlxmVoQ","terms":[{"offset":0,"value":"M G Road Metro Station"},{"offset":24,"value":"Mehrauli-Gurgaon Road"},{"offset":47,"value":"Sector 28"},{"offset":58,"value":"Gurgaon"},{"offset":67,"value":"Haryana"},{"offset":76,"value":"India"}],"types":["transit_station","point_of_interest","establishment","geocode"]},{"description":"MGF MAll Management, DLF City Mall Parking Road, Sector 28, Gurgaon, Haryana, India","id":"c8e8961eb24684f8fa6457876e0f5c1d7c38b5b9","matched_substrings":[{"length":2,"offset":0}],"place_id":"ChIJS3fMbyIZDTkRkexzrN-6sBg","reference":"CnRhAAAApKaoK6e148xwbkJZGhNXNTTDqStbf3vU5b0udThzC0jcdbtJceqWXcQ-I8U_x838GYjHTLLcNNswfrTu3jYVgnA-evtNfhN1pRKnugpvOAtonL2aEYmxGHQadW3bY8uzf-ERjosRBicEb2HfdoKZPhIQvUrFQqXv67CoiaWqlVqXUxoUBccSCK3csfVr1HA0H2HZOiqEmu8","terms":[{"offset":0,"value":"MGF MAll Management"},{"offset":21,"value":"DLF City Mall Parking Road"},{"offset":49,"value":"Sector 28"},{"offset":60,"value":"Gurgaon"},{"offset":69,"value":"Haryana"},{"offset":78,"value":"India"}],"types":["establishment"]},{"description":"MGF Infratech, Gurgaon, Haryana, India","id":"1b4b1ce2e29a7a8f3b3d07192bf06f7e6f0df84f","matched_substrings":[{"length":2,"offset":0}],"place_id":"ChIJTytQ6hgZDTkR2p2nzYt9tfA","reference":"CkQ1AAAAgAsxqmineUN1diGhpF5khDroggPvicHj5VlegMg-SYKf3ORdoFU5JB9dp5lpRY5byp9LAIx3alsDZ0k4D5QCrxIQXi5gMF1JakSfbAufPMlvcRoUqMmrZiUzEmhdiVxMBneGKFLrmZg","terms":[{"offset":0,"value":"MGF Infratech"},{"offset":15,"value":"Gurgaon"},{"offset":24,"value":"Haryana"},{"offset":33,"value":"India"}],"types":["establishment"]},{"description":"MG Road, National Highway 236, Maruti Housing Colony, Gurgaon, Haryana, India","id":"20c271b151605328170192b769e72e3e9bee6056","matched_substrings":[{"length":2,"offset":0}],"place_id":"ChIJrYoVEyIZDTkRcmM4_rRo_OE","reference":"CmRcAAAAtEh471bANMlFV-mDp2hOSVxW0_XxmNFQEmGXCiuZxvjsLvOcoyMPC0VhOifD7ngb-2rs5cfplaomYupeARu3kKEf6WPBQ170Ge7ZRNscQ1PDx12EvHkm4R7MrUD2F_kZEhBq6yvt7WzJgAkdXholeEObGhTuXqJl41XcSz2dzzksTMsHsU7Nzg","terms":[{"offset":0,"value":"MG Road"},{"offset":9,"value":"National Highway 236"},{"offset":31,"value":"Maruti Housing Colony"},{"offset":54,"value":"Gurgaon"},{"offset":63,"value":"Haryana"},{"offset":72,"value":"India"}],"types":["transit_station","point_of_interest","establishment","geocode"]}],"status":"OK"}
我無法理解的情景那爲什麼地方api不適用於Android-Key。請任何人試圖解釋我。
感謝
您是否使用了Javascript庫或Android?....你的服務器密鑰的作品,因爲這是爲網絡那麼你的服務器密鑰將被啓用
在這裏你必須使用API_KEY是服務器密鑰。 SHA-1指紋和密鑰庫用於簽署您的apk,而不是**用於放入網址。 – Andy
我在Android中使用。對於android鍵我把sha-1&包名稱放在谷歌API控制檯中不在URL中。在URL中,我把從api控制檯返回的密鑰。 –
好吧,你仍然不會把你的android密鑰到網址中。 Android密鑰適用於Android應用程序。你會把它放在你項目的清單文件中。對於Google地圖v3(javascript),您可以使用瀏覽器密鑰或服務器密鑰。您可以在Android應用程序中使用v3,因爲您仍然可以執行諸如製作http請求和在webviews中加載內容等內容。請注意,它們應該適用於不同的平臺。從我的問題中可以看出,沒有任何Android相關的必要。 – Andy