cURL Apple iCloud日历订阅链接失败

I've been using cURL in a php web application to fetch ics data from iCloud calendars, but recently it has stopped working. The JSON response is {"reason":"Invalid or missing Origin header","error":1} The link provided by iCloud has the webcal:// protocol, but it has worked in the past to replace it with https://.

Here's the cURL request in PHP:

$request = curl_init();
curl_setopt_array($request, array
    (
    CURLOPT_URL => 'https://p05-calendarws.icloud.com/ca/subscribe/1/D_qOGO6JavMSf055UDaLZJP3SMdywBrlw_w6JkYC1yNJK6R5oxtSOXXXXXXXXXX',
    CURLOPT_POST => FALSE,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_HEADER => FALSE,
    CURLOPT_FOLLOWLOCATION => TRUE
));

$response = curl_exec($request);
curl_close($request);

I think it might be a problem with Apple and their 2 factor authentication that they've been promoting lately. If this is the cause, I found where to get an app-specific password from iCloud, but not sure how to implement that here.

Probably too late to help, but this might only work for published (sharable, read-only) calendars. I tried it with one of mine (and echo'd the $response) and got all the events for my calendar.

CURLOPT_URL => 'https://p35-calendars.icloud.com/published/2/f3en8ZL-G5cgxxxxxxxxx'