New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Outlook ICS failed to open stream: HTTP request failed! #311
Comments
Please fill in the issue template in full - I'm unable to investigate your issue without this |
What more do you need? How to download ICal link?
|
I had the same issue. It seems that Outlook is returning a 400 status because a User-Agent header is missing when the iCal is requested. $agent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://outlook.office365.com/owa/calendar/...");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_USERAGENT, $agent);
$calendar_data = curl_exec($curl);
curl_close($curl);
$ical = new \ICal\ICal(false, [
'defaultWeekStart' => 'MO'
]);
$ical->initString($calendar_data); |
Thx @gafderks With the modification below or a way to set the userAgent via the constructor would be a better fix. |
You can already define a custom user agent: 205afb3 |
Ye but thats not via the constructor. The best fix would be is to add 'httpUserAgent' to the $configurableOptions. Or add the agent as default bc everybody that uses outlook links would need this. |
Feel free to raise a PR |
The issue seems to be related to the Host header, not the user-agent header. We've currently worked around this by downloading the file using Guzzle and then passing it to ICal with use GuzzleHttp\Client as GuzzleClient;
use ICal\ICal;
$iCalFile = (new GuzzleClient())->get($iCalUrl)->getBody()->getContents();
$iCal = new ICal(false, []);
$iCal->initString($iCalFile); |
@u01jmg3 I created a PR |
I'm still receiving "failed to open stream: HTTP request failed! HTTP/1.1 400". Any updates on this issue? |
The code is not yet released. Watch out for |
@u01jmg3 thanks! |
7.4 & 8.1
Europe/Amsterdam
2.1.19 & 3.1.1
Description of the Issue:
When adding an outlook ICS link I get the PHP error failed to open stream: HTTP request failed! HTTP/1.1 400
Steps to Reproduce:
The text was updated successfully, but these errors were encountered: