Authentication: Sync Distribution

The POOL API uses a more streamlined method of keeping track of a user's release distribution. So it is recommended to run the Sync Distribution command on first sign in and everytime a view is loaded or refreshed so that the releases/tracks are the most up to date with what has been released. This endpoint will allow for quick distribution syncing between the older system and the newer system.

Sync Distribution Specification:

Parameters: Header variables:
  1. userid: integer
  2. token: string
Data returned:

Sync Distribution Work Flow

  1. URL: https://api.promoonly.com/user/sync
  2. Header: Authorization: Bearer Base64(userid:token)
  3. Method: GET
  4. Returned: JSON

    Example JSON Output:

    {
        "userid": 1,
        "distribution": "Releases synced for userid: 1"
    }
    - OR -
    {
        "userid": 1,
        "distribution": "Invalid user."
    }

Examples

  1. PHP (using cURL):

    <?php
        $userid = 1;
        $token = "8b26e1e4f3f5e00a888807e605565c47";
        $sync_url = "https://api.promoonly.com/user/sync";

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $sync_url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".base64_encode($userid.":".$token)));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        $sync_result = curl_exec($ch);
        curl_close($ch);

        $sync_obj = json_decode($sync_result);
    ?>
  2. Javascript (using jQuery):

    function b64EncodeUnicode(str)
    {
        return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
            function toSolidBytes(match, p1)
            {
                return String.fromCharCode('0x' + p1);
            }));
    }

    var userid = 1;
    var token = "8b26e1e4f3f5e00a888807e605565c47";
    var auth_str = "Bearer " + b64EncodeUnicode(userid + ":" + token);

    $.ajax({
        type: "GET",
        url: "https://api.promoonly.com/user/sync",
        headers: { "Authorization": auth_str },
        dataType: "json",
        success: function (data)
        {
            console.log(data);
        }
    });
  3. Python (using requests):

    #!/usr/bin/env python

    import requests
    import base64
    import urllib

    userid = 1
    token = "8b26e1e4f3f5e00a888807e605565c47"

    b64_key = base64.b64encode("%s:%s" % (userid, token))
    headers = {"Authorization": "Bearer %s" % b64_key}
    sync_url = "https://api.promoonly.com/user/sync"
    result_return = requests.get(sync_url, headers=headers)

    print(result_return.text)