Guide to using Yun software interface

Using the Api provided, you can get the Link shortening service in your applications and websites.   The design of this interface is very simple and you can connect your services to it in less than 10 minutes.

Create Token

You will need a validation token to connect to the Yun Api.

To verify the owner of the request, you must put it in the request header.

'X-API-Key: put-your-token-here',

 

To receive your own token, after joining and entering your subscription, refer to the tokens section. Click on the link below to refer to this section.

Create New Token

Send Request

After producing and receiving your own token, you can now send your request to receive the service. If you submit a valid request, the ID and the link related to your request will be provided in response to you. If you need to send an update request or delete it, you will need this ID, so save it to your database.

Sample executable code

In the following section, you will see a sample PHP code to send a request to shorten the link. To see more technical details, please refer to the following link.

See technical details on how to submit an application

 


function __short_url($title, $url)
{
    $data = json_encode([
        "title" => $title,
        "url" => $url,
    ]);

    $ch = curl_init('https://yun.ir/api/v1/links');
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
            'Content-Type: application/json',
            'X-API-Key: put-your-token-here',
            'Content-Length: ' . strlen($data)
    ]);

    $result = curl_exec($ch);
    return json_decode($result, 1);
}

$result = __short_url('Telegfa', 'http://telegfa.com');
var_dump($result);

/*
array(2) {
  ["id"] => int(24057)
  ["url"] => string(13) "yun.ir/5orqga"
}
*/