Modified the code to prevent encountering a “Bad Gateway” 502 error. Successfully implemented the PHP cron job for retrieving daily metrics.