0

http://goo.gl/によって短縮 URL が作成されました 。元の URL を取得する必要があります。ANDROIDでそれを行うためのAPIはありますか.

短くするために試したこと-

「com.andreabaccega:googlshortenerlib:1.0.0」をコンパイルします

GoogleShortenerPerformer shortener = new GoogleShortenerPerformer(new OkHttpClient());

String longUrl = "http://www.andreabaccega.com/";

GooglShortenerResult result = shortener.shortenUrl(
    new GooglShortenerRequestBuilder()
        .buildRequest(longUrl)
    );

if ( Status.SUCCESS.equals(result.getStatus()) ) {
    // all ok result.getShortenedUrl() contains the shortened url!
} else if ( Status.IO_EXCEPTION.equals(result.getStatus()) ) {
    // connectivity error. result.getException() returns the thrown exception while performing
    // the request to google servers!
} else {
    // Status.RESPONSE_ERROR
    // this happens if google replies with an unexpected response or if there are some other issues processing
    // the result.

    // result.getException() contains a GooglShortenerException containing a message that can help resolve the issue!
}
4

2 に答える 2