Actually this is not an mql issue.
You need to learn a bit how http requests are working. To use basic authentication, you have to use request headers.
The forexfactory.net URL works OK for me. It looks like they have blocked some user-agents on the .com URL. I guess they want to move the RSS traffic over to the .net URL. I got the .com URL to work by changing the user-agent.
void OnStart()
{
string cookie=NULL, headers;
string reqheaders="User-Agent: Mozilla/4.0\r\n";
char post[],result[];
int res;
string url="http://www.forexfactory.com/ffcal_week_this.xml";
ResetLastError();
int timeout=5000;
res=WebRequest("GET",url,reqheaders,timeout,post,result,headers);
if(res==-1)
{
Print("Error in WebRequest. Error code =",GetLastError());
//--- Perhaps the URL is not listed, display a message about the necessity to add the address
MessageBox("Add the address '"+url+"' in the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
}
else
{
//--- Load successfully
PrintFormat("The file has been successfully loaded, File size =%d bytes.",ArraySize(result));
//--- Save the data to a file
int filehandle=FileOpen("test.xml",FILE_WRITE|FILE_BIN);
//--- Checking errors
if(filehandle!=INVALID_HANDLE)
{
//--- Save the contents of the result[] array to a file
FileWriteArray(filehandle,result,0,ArraySize(result));
//--- Close the file
FileClose(filehandle);
}
else Print("Error in FileOpen. Error code=",GetLastError());
}
}
Please do some searches before posting. Thanks.