php api throws exception on network failure