Home

Sign In Sign Up

To obtain an API key you must first sign up. After obtaining an API key, you can use PHP cURL to shorten a URL remotely.
<?php
    //Required parameters
    $link    = ""; //The link you want to shorten, this could be predefined or grabbed from a HTML form.
    $api_key = ""; //API key from the accounts page http://mub.me/p/account.

    //Optional parameters.
    $link_alias      = ""; //Your custom link alias, leave/remove this for auto-generation.
    $link_password   = ""; //Link password, leave/remove this for no password locking.
    $visitor_message = ""; //Specify a messge for your visitor, leave/remove this for no redirect message.

    $ch  = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_URL, "http://mub.me/api.php");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    $params   = array("link"            => $link,
                      "api_key"         => $api_key,

                      "link_alias"      => $link_alias,
                      "link_password"   => $link_password,
                      "visitor_message" => $visitor_message);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    $response = curl_exec($ch);
    $response = json_decode($response, true); //API response will be JSON encoded.
    curl_close($ch);
    echo $response['status']."\n"; //Status of request, error/success
    echo $response['message']; //Message of the request, either a error message or the actual requested link.
?>