Giter Club home page Giter Club logo

ampacheapi-php's Introduction

ampacheapi-php

Ampache API PHP Library.

NEWS

Version 2 of this library is underway.

There are major changes to help support multiple purporses as well as both XML and JSON responses.

The library will now return a SimpleXMLElement or json_encode string instead of the frankenstein.

This version of the library is supported from Ampache 6.2.0+

License

Ampache API PHP Library is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3 (AGPLv3) as published by the Free Software Foundation.

Get Started

Initialize

$ampache = new AmpacheApi(array(
   'username' => 'user1', // Username
   'password' => 'test', // Password
   'server' => 'localhost', // Server address, without http/https prefix
   'debug_callback' => 'debug_event', // server callback function
   'api_secure' => 'false' // Set to true to use https
   'api_version' => 6 // Set API response version. 3, 4, 5, 6 (default: 6)
   'api_format' => 'xml' // Set API response format. xml, json (default: json)
));

if ($ampache->state() != 'CONNECTED') {
  echo "Ampache API client failed to connected.\n";
  exit;
}

Get server stats

$stats = $ampache->info();
echo "Songs: " . $stats->songs . "<br />\n";
echo "Albums: " . $stats->albums . "<br />\n";
echo "Artists: " . $stats->artists . "<br />\n";
echo "Playlists: " . $stats->playlists . "<br />\n";
echo "Videos: " . $stats->videos . "<br />\n";

Get all artists

$total = $stats->artists;
$step = 500; // Request per 500
$start = 0;

echo "Artists: <br />\n";
while ($total > $start) {
  $artists = $ampache->send_command('artists', array('offset' => $start, 'limit' => $step));
  foreach ($artists as $artist) {
    echo "\t" . $artist->name . "\n"
  }
}

ampacheapi-php's People

Contributors

afterster avatar gloony avatar lachlan-00 avatar olaulau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ampacheapi-php's Issues

Sometime, self attribute cannot be set

If happend somtime that the error "PHP Warning: Illegal string offset 'self' in AmpacheAPI.php Line 382" is displayed.
To avoid this error I change this line by this :

if(isset($this->XML_results[$this->XML_position][$this->XML_currentTag][$this->XML_subTag]) && is_array($this->XML_results[$this->XML_position][$this->XML_currentTag][$this->XML_subTag])) {
    $this->XML_results[$this->XML_position][$this->XML_currentTag][$this->XML_subTag]['self'] = $attributes;
}

Pull #3

Error for connection

At line 123 of AmpacheApi.php, the password must be hashed in sha before sended to server.
So remove line 123

$passphrase = hash('sha256', $timestamp . $this->password);

And remplace by this

$key = hash('sha256', $this->password);
$passphrase = hash('sha256', $timestamp . $key);

Pull #3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.