Exemple #1
0
/**
 * Interactions with API handled here
 *
 * @param $file_path
 */
function send_file($file_path, $type)
{
    $payload = array();
    $full_file_path = realpath($file_path);
    if (file_exists($full_file_path)) {
        $file_path_parts = pathinfo($full_file_path);
        $payload['name'] = $file_path_parts['filename'];
        $payload['file-name'] = $file_path_parts['basename'];
        $file_contents = file_get_contents($full_file_path);
        $payload['file-data'] = base64_encode($file_contents);
    }
    // Loads creds from cookie
    $cred_array = array("username" => $_COOKIE['username'], "password" => $_COOKIE['password']);
    $api = new API_Thingy($cred_array);
    $api->post($type, $payload);
}
Exemple #2
0
 /**
  * Put the file in queue to be played
  *
  * @param string $file
  * @param string $file_type
  */
 function queue($file = '', $file_type = 'song')
 {
     $endpoint = 'queue';
     $payload = array("file" => $file, "file_type" => $file_type);
     $api = new API_Thingy($this->credentials);
     $api->post($endpoint, $payload);
 }