This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

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.

OperationDescription

getShorten

Given a long URL, returns a bitly short URL.

getExpandGiven a bitly URL or hash (or multiple), returns the target (long) URL.
getInfoThis is used to return the page title for a given bitly link.
getLinkSaveSaves a link as a bitmark in a user's history, with optional pre-set metadata.
getLookupThis 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.

Returns a bitly short URL

The getLinkInfo operation Given a long URL, returns a bitly short URL .

getLinkInfo
<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.

Sample Request for getShorten
{
"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

Returns the target (long) URL .

The getExpand operation Given a bitly URL or hash (or multiple), returns the target (long) URL .

getExpand
<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.

Sample Request for completeContext
{
"shortUrl":"http://bbc.in/1ngHJH4"
}
Related Bitly documentation

http://dev.bitly.com/links.html#v3_expand

The getInfo operation Returns the page title for a given bitly link .

getInfo
<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.

Sample Request for getInfo
{
"shortUrlforInfo":"http://bbc.in/1ngDL1b",
"expandUserinfo":"true"
}
Related Bitly documentation

http://dev.bitly.com/links.html#v3_info

Searching links receiving clicks across bitly by content

The getSearch operation Getting popular bitly links at this particular moment .

getSearch
<bitly.getSearch>
     <query>{$ctx:query}</query>            
     <noOfLinks>{$ctx:noOfLinks}</noOfLinks>            
     <fields>{$ctx:fields}</fields>             
     <domain>{$ctx:domain}</domain>    
</bitly.getSearch>
Properties
  • query: String to query for.

  • nooflinks: The maximum number of links to return.

  • fields: which fields to return in the response (comma-separated).

  • offset: which result to start with (defaults to 0).

Sample request

Following is a sample REST/JSON request that can be handled by the getSearch operation.

Sample Request for getSearch
{
"query":"flower",
"noOfLinks":"2",
"fields":"aggregate_link%2Ctitle%2Curl",
"domain":"flower"
}
Related Bitly documentation

http://dev.bitly.com/data_apis.html#v3_search

Sample configuration

Following is a sample proxy service that illustrates how to connect to Bitly with the init operation and use the getLinkInfo operation. The sample request for this proxy can be found in getLinkInfo sample request.

Sample Proxy
<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.getLinkInfo>
            <bitlyLink>{$ctx:bitlyLink}</bitlyLink>
         </bitly.getLinkInfo>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>
  • No labels