Documentación de la API para anon.click



Ejemplo de código


                                
<?php
/**
 * return a short-url
 * @link https://anon.click/api/
 * @param string $url input url
 * @param string $password=null
 * @param boolean $captcha=false
 * @return string|null shortURL e.g. https://anon.click/4jdh39f or null if error
 */
function anon_click($url, $password=null, $captcha=false){
    $bURL='https://anon.click/api/shortURL';

    $data = json_encode(array(
        'url'      => $url,
        'password'    => $password,
        'captcha'       => $captcha
    ));

    $context  = stream_context_create( array(
        'http' => array(
            'method'  => 'POST',
            'content' => $data ,
            'header'=>  "Content-Type: application/json\r\n" .
                "Accept: application/json\r\n"
        )
    ) );
    try{
        $result = @file_get_contents( $bURL, false, $context );
        $response = json_decode( $result );
        if(isset($response->url)){
            return $response->url;
        }else{
            return null;
        }
    }catch(Exception $e){
        return null;
    }
}

//example call
echo "shortURL: ".anon_click('https://www.whatismyreferer.com/', 'foobar', false);

?>
                            

                                
/**
 * return a short-url
 * @link https://anon.click/api/
 * @param {string} url
 * @param {string|null} password if needed or null if no password
 * @param {boolean} captcha true if captcha needed
 * @param {function(string|null)} cb - callback with url e.g. https://anon.click/s4fg67j   - null if error
 */
function anon_click(url, password, captcha, cb) {
    try {
        var bURL = 'https://anon.click/api/shortURL';
        require('request')({
            method: 'post',
            body: {
                url: url,
                password: password,
                captcha: captcha
            },
            json: true,
            url: bURL
        }, function (err, res, body) {
            if (err) {
                console.error("anon_click error: ");
                console.dir(err);
                cb(null);
                return false;
            }


            if (body.url) {
                cb(body.url);
            } else {
                cb(null);
            }

        });
    } catch (e) {
        console.error("anon_click error:");
        console.dir(e);
        cb(null);
    }
}

//example-call
anon_click('https://www.whatismyreferer.com/', 'foobar', false, function (shortURL) {
    console.log('Short-URL created: ' + shortURL);
});