okwinza / icecast2-php-api

A powerful and flexible REST API for IceCast2 written in PHP
52 stars 12 forks source link

Bad request #3

Closed nickw108 closed 7 years ago

nickw108 commented 9 years ago

Thanks for sharing this!

I'm not sure if I understand the usage correctly. I've installed via composer on my local machine under MAMP (OS X), but when I go to http://localhost:8888/misc/icecast2-php-api/ I get the following error:

{"type":"400","message":"Bad request"}

I also tried http://localhost:8888/misc/icecast2-php-api/listeners/xml/ according to your example http://api.tort.fm/radio/tort.fm/listeners/xml/ which returns the same 400 bad request error with no errors neither in Apache nor PHP error logs. Btw, your examples do no longer seem to work ;-)

Any ideas what I might be missing here?

okwinza commented 9 years ago

Hello, @nickw108!

Try http://localhost:8888/{your_icecast_mount_name}/listeners/xml/

It should work assuming you've configured your icecast2 mountpoints correctly.

nickw108 commented 9 years ago

Thanks for the quick response, @okwinza!

Did you mean http://localhost:8888/misc/icecast2-php-api/{your_icecast_mount_name}/listeners/xml/?

If I use my mount 128k.mp3 it returns the following trace:

Slim Application Error
The application could not run because of the following error:
Details
Type: ErrorException
Code: 8
Message: Undefined offset: 0
File: /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/icecast_api.php
Line: 118
Trace
#0 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/icecast_api.php(118): Slim\Slim::handleErrors(8, 'Undefined offse...', '/Applications/M...', 118, Array)
#1 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/icecast_api.php(56): IcecastApi->GetListenersAction(Array)
#2 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/index.php(42): IcecastApi->Request('GetListeners', Array)
#3 [internal function]: {closure}('128k.mp3', 'xml')
#4 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/vendor/slim/slim/Slim/Route.php(468): call_user_func_array(Object(Closure), Array)
#5 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/vendor/slim/slim/Slim/Slim.php(1357): Slim\Route->dispatch()
#6 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/vendor/slim/slim/Slim/Middleware/Flash.php(85): Slim\Slim->call()
#7 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/vendor/slim/slim/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()
#8 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
#9 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/vendor/slim/slim/Slim/Slim.php(1302): Slim\Middleware\PrettyExceptions->call()
#10 /Applications/MAMP/htdocs/kirtan/misc/icecast2-php-api/index.php(132): Slim\Slim->run()
#11 {main}

Or do I have to run the PHP script directly on the Icecast server?

okwinza commented 9 years ago

Its preffered to have this script installed on the same machine for log parser to work. Other services like listeners online should be fine regardless.

There is some icecast magic here: ic2 mountpoint names do not include extensions(.mp3/.m3u). Basically, if the link you put in your mp3 player looks like "%icecast2_url%/128k.mp3", then you should use "128k" as the actual mountpoint name.

Or you could just see into your client software that sends mp3 stream to icecast.

Thanks for your feedback, hope it helps.

okwinza commented 7 years ago

Closing this for now, please reopen if the issue is still present.