Shorten Url with CatCut API

Today’s web provides many opportunities to shorten links. Short links can be useful for a variety of purposes, such as sending them to messengers or posting them on social networks. Therefore, we suggest shortening links in a few clicks with CatCut.net.

In parallel, you can make money as well.

Links often contain a lot of extra information or special characters. Specifically, this information is not useful and as a result, these links have a lot of space in the messages or on Web pages.

How to Shorten a Link in CatCut

In fact, the procedure itself is as simple as possible.

Copy and paste the original link, then click the “Shorten Link” button. In a new window, you will get a version of the shortened link. If you have the shortened link, you can switch on/off the ad for the link.

After the paid advertisement has been shown the owner earns a certain amount of money. Each unique visitor’s view is paid for.

With more views and conversions owner of the link earns more. Therefore, we encourage you to shorten as many links as possible.

How to Shorten a Url Programmatically

To shorten a link programmatically, you can use the “Link Handler”. To do that, click the link at the top of the screen, see the screenshots above.

Register the Link Handler

Before you start working with shortened URLs programmatically, you need to register with a secret key and ID. Under “Link Handler” click on “Add a Handler”. Then complete the registration by clicking the “Add” button.

Link Generation Example

URL: http://ccl.su/go.php

Instead of ccl.su domain, you can use your own domain from the “My Domains” section or any of our domains from the short links section.

GET transition parameters:

h_i (mandatory) ID of your handler, the number that comes after the #H characters in the handler control panel on CatCut (for example, you should send 123 for handler #H123);
h_u(mandatory) Base64-encoded URL.
h_aUnique transition ID for generating the signature (see section “Verification of transition by the link”). 40 – 60 characters, only upper and lower case Latin letters, numbers and underscore “_” are allowed.
sif set to “1”, the transition source (HTTP referrer) will be hidden, including catcut.net itself. It works only if the link from parameter h_u is on HTTP protocol.

Example

The usual link to the Google homepage:

https://google.com

Link to Google homepage with ad views via #H7 handler

http://ccl.su/go.php?h_i=7&h_u=aHR0cHM6Ly9nb29nbGUuY29t

Check Link Clicks

You can check the uniqueness of each click. This may be necessary to verify that the view was made through a processed link, and not directly, without viewing ads. To do this, generate a unique view ID for each link and put it to the parameter h_a.

Example of Generation of Unique View ID (GET Parameter h_a)

You can provide the sequence number for the link and add 40 random Latin characters to it with an underscore (“_”). For each view use a new ID and new random characters. For example, the view sequence number is 712532. Thus the unique view ID is 712532_GBYHqazWSXEDCrfvTGByhnUJMikOLpQAZwsxRFVt

Link Signature

If the h_a parameter is passed, a signature will be added to your link, which will be clicked after viewing the ad, in the form of an additional GET parameter ccviewsign. The ccviewsign GET parameter consists of a unique link ID (value of the h_a parameter) with a hyphen SHA-1 hash of a unique link ID and a secret handler code. Check on the server side hash and if the transition with this ID was done before. If the hash is correct and there were no previous view with this ID, you can provide access to the page.

To check the hash, take the unique ID of the transition (a part before the hyphen of ccviewsign parameter) and the secret code of the handler from the handler control panel on the CatCut. Glue the ID and the secret code one to one and get the SHA-1 hash of this string. Check the received hash against the one that came (the part after the hyphen of ccviewsign), they must be identical.

Example of How a Link Signature Works (GET of ccviewsign Parameter)

If you process a link http://my-site.com/secret-file with the GET parameter h_a then after viewing the advertisement the link will go to http://my-site.com/secret-file?ccviewsign=UNIC_ID-HASH. That is your link will be complemented with the ccviewsign parameter with the value UNIC_ID-HASH. Where UNIC_ID is equal to the GET parameter h_a, then a hyphen, then HASH is equal to SHA-1 hash of UNIC_ID and secret handler code.

Generating URLs with PHP

A simple PHP function to generate links cc_url_handler

Function parameters

idHandler ID.
urlLink to go to.
askUnique transition ID, default is false.
sFlag to hide HTTP referrer, true or false, default is false.
<?php
function cc_url_handler ($id, $url, $ask = false, $s = false) {
    $result = "http://ccl.su/go.php?h_i=$id";
    $url = base64_encode($url);
    $result .= "&h_u=$url";
    if($ask){
        $result .= "&h_a=$ask";
    }
    if($s){
        $result .= "&s=1";
    }
    return $result;
}
?>

Example usage

Generate an unsigned link to google.com, for handler #H7 (replace with your own).

<?php $cc_link = cc_url_handler(7, "https://google.com"); ?>

Conclusion

If you have a personal site and you use it to distribute content in files. This can be music, video, or some service files, you can show ads with shortened URLs, thereby replenishing your money balance.

Related posts

Leave a Comment