Debugged

I amended the code a bit to make it work again, and created an example php file for using.

Thanks.