Overview
The following operations allow you to work with Links. Click an operation name to see details on how to use it.
For a sample proxy service that illustrates how to work with links, see Sample configuration.
Operation | Description |
---|---|
Given a long URL, returns a bitly short URL. | |
getExpand | Given a bitly URL or hash (or multiple), returns the target (long) URL. |
getInfo | This is used to return the page title for a given bitly link. |
getLinkSave | Saves a link as a bitmark in a user's history, with optional pre-set metadata. |
getLookup | This is used to query for a bitly link based on a long URL. |
Operation details
This section provides further details on the operations related to link.
Get a bitly short URL
The
getShorten operation
returns a bitly short URL .
<bitly.getShorten> <longtUrlforShorten>{$ctx:longtUrlforShorten}</longtUrlforShorten> <bitlyShortDomain>{$ctx:bitlyShortDomain}</bitlyShortDomain> </bitly.getShorten>
Properties
longUrl:a
long URL to be shortened
domain:
(optional) the short domain to use; either bit.ly, j.mp, or bitly.com or a custom short domain
Sample request
Following is a sample REST/JSON request that can be handled by the getShorten
operation.
{ "longUrl":"http://eclipsesource.com/blogs/2009/05/12/osgi-declarative-services/", "domain":"nytimes.com" }
Related Bitly documentation
http://dev.bitly.com/links.html#v3_shorten
Get the target (long) URL .
The getExpand
operation returns the target (long) URL .
<bitly.getExpand> <shortUrl>{$ctx:shortUrl}</shortUrl> </bitly.getExpand>
Properties
shortUrl
: refers to one or more bitly links
Sample request
Following is a sample REST/JSON request that can be handled by the getExpand
operation.
{ "shortUrl":"http://bbc.in/1ngHJH4" }
Related Bitly documentation
http://dev.bitly.com/links.html#v3_expand
Get the page title for a given bitly link
The
getInfo
operation returns the page title for a given bitly link .
<bitly.getInfo> <shortUrlforInfo>{$ctx:shortUrlforInfo}</shortUrlforInfo> <expandUserinfo>{$ctx:expandUserinfo}</expandUserinfo> </bitly.getInfo>
Properties
shortUrlforInfo: Refers to one or more bitly links.
expandUserinfo: (optional) true| false – include extra user info in response.
Sample request
Following is a sample REST/JSON request that can be handled by the
getInfo
operation.
{ "shortUrlforInfo":"http://bbc.in/1ngDL1b", "expandUserinfo":"true" }
Related Bitly documentation
http://dev.bitly.com/links.html#v3_info
Saving a link as a bitmark in a user's history, with optional pre-set metadata
The
getLinkSave
operation saves a link as a bitmark in a user's history, with optional pre-set metadata .
<bitly.getLinkSave> <longtUrlforLinkSave>{$ctx:longtUrlforLinkSave}</longtUrlforLinkSave> <titleforLink>{$ctx:titleforLink}</titleforLink> <noteforLink>{$ctx:noteforLink}</noteforLink> </bitly.getLinkSave>
Properties
longtUrlforLinkSave: string to query for.
titleforLink: (optional) the title of this Bitlink.
noteforLink: (optional) a description of, or note about, this Bitlink.
private: (optional) boolean true or false indicating privacy setting (defaults to user-level setting).
Sample request
Following is a sample REST/JSON request that can be handled by the
getLinkSave
operation.
{ "longtUrlforLinkSave":"http://www.myfootballgames.co.uk/game/353/World-Cup-Penalty.html", "titleforLink":"http://bit.ly/Tvs4M4", "noteforLink":"http://bit.ly/Tvs4M4" }
Related Bitly documentation
http://dev.bitly.com/links.html#v3_user_link_save
Query for a bitly link based on a long URL
The
getLookup
operation gets a link based on a long URL .
<bitly.getLookup> <urlforLookup>{$ctx:urlforLookup}</urlforLookup> </bitly.getLookup>
Properties
urlforLookup: an echo back of the url parameter.
Sample request
Following is a sample REST/JSON request that can be handled by the
getLookup
operation.
{ "urlforLookup":"http://google.com/" }
Related Bitly documentation
Sample configuration
Following is a sample proxy service that illustrates how to connect to Bitly with the init
operation and use the getShorten
operation. The sample request for this proxy can be found in getLinkInfo sample request.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="bitly" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <property name="accessToken" expression="json-eval($.accessToken)"/> <property name="bitlyLink" expression="json-eval($.bitlyLink)" /> <bitly.init> <accessToken>{$ctx:accessToken}</accessToken> </bitly.init> <bitly.getShorten> <longtUrlforShorten>{$ctx:longtUrlforShorten}</longtUrlforShorten> <bitlyShortDomain>{$ctx:bitlyShortDomain}</bitlyShortDomain> </bitly.getShorten> <respond/> </inSequence> <outSequence> <send/> </outSequence> </target> <description/> </proxy>