api.php: Another empty()-related fixes (It works in 5.6 but not in 5.3)

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>