1
私はこのコードを使用して私のロングURLを短縮しています。私は何か間違っている?URLショートネーナ(GoogleのAPIキーを使用)
Urlshortener.Builder builder = new Urlshortener.Builder (AndroidHttp.newCompatibleTransport(),
AndroidJsonFactory.getDefaultInstance(), null);
Urlshortener urlshortener = builder.build();
com.google.api.services.urlshortener.model.Url url = new com.google.api.services.urlshortener.model.Url();
url.setLongUrl(longUrl);
try {
Urlshortener.Url.Insert insert=urlshortener.url().insert(url);
insert.setKey(key);
url = insert.execute();
return url.getId();
} catch (IOException e) {
return null;
}
しかし、それは私に例外を与えます。
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "The Android package name and signing-certificate fingerprint, null and null, do not match the app restrictions configured on your API key. Please use the API Console to update your key restrictions.",
"reason": "ipRefererBlocked",
"extendedHelp": "https://console.developers.google.com/apis/credentials?project=796104768654"
}
],
"message": "The Android package name and signing-certificate fingerprint, null and null, do not match the app restrictions configured on your API key. Please use the API Console to update your key restrictions."
}
キーを追加しました。また、パッケージ名とSHA-1指紋をGoogleコンソールに追加しました。まだ私にエラーを与える – Sanket
しかし、それは彼のエラーによると、あなたはあなたのテストをAPKに署名していないと思われる。署名付きのパッケージをエクスポートしましたか?または実行中のデバッグ – tik27
はい。私はAPKに署名した。 – Sanket