PHP code example of yeboahnanaosei / acoust

1. Go to this page and download the library: Download yeboahnanaosei/acoust 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/ */

    

yeboahnanaosei / acoust example snippets


try {
    // Set the needed parameters
    $song   = 'Path to song';      # Always  'json or xml'        # Optional. Defaults to 'json' if not supplied

    // Create instance of acoust
    // $format is optional and can be omitted
    // In that case $format will default to 'json'
    $acoust = new Acoust($apiKey, $song, $format);

    // All you need to do is to just call query() method
    // This method will return data from acoustid.org in
    // json format by default or in xml if you set your
    // format to xml
    $response = $acoust->query();
} catch (Throwable $e) {
    echo $e->getMessage();
}

try {
    // Set needed parameters
    $song = 'Path to song';

    // Create an instance of acoust
    $acoust = new Acoust($song)

    // Generate fingerprint or duration of the song as you wish
    $fingerprint = $acoust->getFingerprint();
    $duration = $acoust->getDuration();


} catch (Throwable $e) {
    echo $e->getMessage();
}