Fixed Undefined Variable Error

Because `$API_KEY` wasn't declared global within the function, it couldn't be accessed.