谷歌的API API_KEY使用一個例子,我發現了地圖API如何配置在Android
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your_api_key"/>
現在我試圖用calandar API的android:name
屬性,我已經成功至今。 。我不確定我應該在這裏使用的android:name
值。
<meta-data
android:name="com.google.android.calendar.v3.API_KEY"<!-- the value ?-->
android:value="your_api_key"/>
響應:
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Access Not Configured",
"reason": "accessNotConfigured"
}
],
"message": "Access Not Configured"
}
有誰知道還有什麼我需要做的正確配置呢?
call google api:CalendarList feed = client.calendarList().list().setFields(CalendarInfo.FEED_FIELDS).execute();
//Traffic Reports for API Project
Total requests
2
Requests/day
2 peak 0.07 average
Start Date
Jun 12, 2013
解決它:
的的Manifest.xml
<application ... >
<meta-data
android:name="com.google.android.calendar.v3.API_KEY"
android:value="your api key"/>
....
</application>
谷歌API訪問:https://code.google.com/apis/console 1.如果你調試,需要添加一個應用程序,客戶端ID用於安裝 應用程序:證書指紋(SHA1):「keytool -list -v -keystore〜/ .android/debug.keystore輸入密碼:機器人」 2.應用程序類型:Android 3.找到API KEY:簡單API訪問 - >鍵爲瀏覽器的應用程序(與 參照網址) - > API密鑰:dhjkl..hjkl 4.找到產品名稱:品牌信息 - >產品名稱
然後調用API:
final HttpTransport transport = AndroidHttp.newCompatibleTransport();
final JsonFactory jsonFactory = new GsonFactory();
GoogleAccountCredential credential;
credential =
GoogleAccountCredential.usingOAuth2(getActivity(),
Collections.singleton(CalendarScopes.CALENDAR_READONLY));
credential.setSelectedAccountName("myAccount");
client = new com.google.api.services.calendar.Calendar.Builder(
transport, jsonFactory, credential).setApplicationName("myAppName")
.build();
...
checkGooglePlayStatus()
...
...
//doInBackground()
CalendarList feed = client.calendarList().list().setFields(CalendarInfo.FEED_FIELDS).execute();
...
如何使用日曆API第3版谷歌網站的例子來驗證你在'manifest.xml'中添加了''嗎?你可以發貼嗎? –
marshallino16
你試圖訪問哪個日曆api? – Sharj
日曆API V3 – qinmiao