public class GoogleURLShortener extends Object
IURLShortener
that uses Google URL shortening service (Goo.gl). Besides the API URL, the Google service
requires an API key.Modifier and Type | Field and Description |
---|---|
static String |
PARAMETER_API_KEY
API key property bag key.
|
static String |
PARAMETER_URL
This is the URL parameter to be used in API URLs.
|
Constructor and Description |
---|
GoogleURLShortener() |
Modifier and Type | Method and Description |
---|---|
String |
expand(String url)
Expands the given URL.
|
String |
getApiKey()
Returns the API key from the
parameters . |
protected String |
getApiURL()
Returns the URL shortener API URL to be used.
|
protected String |
postData(String url)
Post data to Google's shortening service and returns the parsed shortened
URL.
|
String |
shorten(String url)
Shortens a given URL.
|
public static final String PARAMETER_API_KEY
public static final String PARAMETER_URL
protected String getApiURL()
public String shorten(String url) throws PortalException
IURLShortener
shorten
in interface IURLShortener
url
- the URL to be shortened.PortalException
- if some error occur in shortening process.protected String postData(String url) throws Exception
url
- the long URL.Exception
public String getApiKey() throws PortalException
parameters
.parameters
.PortalException
- if the API key is not set in parameters
.public String expand(String url) throws PortalException
url
- the URL to be expanded.PortalException
Lumisportal 10.1.2.170428 - Copyright © 2006–2017 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.