PHP to read secured file

前端 未结 2 1071
一整个雨季
一整个雨季 2021-01-19 05:46

I have a xml-file on subdomain a, and a php script on subdomain b. I want to read, and use, the data from the XML file, through PHP.

Here\'s the catch. The file is s

2条回答
  •  长情又很酷
    2021-01-19 06:50

    The url wrappers support URLs of the form http://USER:PASS@yourdomain.com/foo/bar so you could simply use file_get_contents.

    Alternatively, you could fetch it with cURL, either shelling out to use a curl command line, or using the curl extension. Failing that, you could hand code the request using fsockopen etc. Basic authentication is called Basic for a reason - it's trivially easy to implement: here's one user-submitted example in the manual.

提交回复
热议问题