API example code for PHP