PHP code example of urlr / urlr-php

1. Go to this page and download the library: Download urlr/urlr-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

urlr / urlr-php example snippets






name = getenv('URLR_API_USERNAME'); // to be defined on your side
$password = getenv('URLR_API_PASSWORD'); // to be defined on your side

// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
$client =  new GuzzleHttp\Client();

$configuration = URLR\Configuration::getDefaultConfiguration();

// Access Tokens

$accessTokensApi = new URLR\Api\AccessTokensApi($client, $configuration);
$createAccessTokensRequest = new \URLR\Model\CreateAccessTokenRequest([
    'username' => $username,
    'password' => $password,
]);

try {
    $token = $accessTokensApi->createAccessToken($createAccessTokensRequest)->getToken();
} catch (Exception $e) {
    echo 'Exception when calling AccessTokensApi->createAccessToken: ', $e->getMessage(), PHP_EOL;
    exit;
}

$configuration->setAccessToken($token);

// Create a link

$linksApi = new URLR\Api\LinksApi($client, $configuration);

$createLinkRequest = new \URLR\Model\CreateLinkRequest([
    'url' => '',
    'teamId' => '',
]);

try {
    $link = $linksApi->createLink($createLinkRequest);
} catch (Exception $e) {
    echo 'Exception when calling LinksApi->createLink: ', $e->getMessage(), PHP_EOL;
}
bash
composer