I have a text file filled with a list of IDs. Using PHP, I am trying to load a url for each of the IDs and pull something from that page (another id)
For example, if I have the IDs 555, 888, 222 I want to load the URLs
http://example.edu/bvl.P_Sel?facultyID=555
http://example.edu/bvl.P_Sel?facultyID=888
http://example.edu/bvl.P_Sel?facultyID=222
I tried to get the content viafile_get_contents("http://example.edu/bvl.P_Sel?facultyID=$lines[0]");
where $lines is an array of the IDs. This returns the following error:
Warning: file_get_contents(http://example.edu/bvl.P_Sel?facultyID=222) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404
That url is an example, but the url in the error does work when I visit it manually. And if I replace the file_get_contents variable with an actual ID, like ?facultyID=222
, it works perfectly.
I visited this question's answer How to post data in PHP using file_get_contents? and tried assigning a variable in the $postdata array to a variable, and I get the same exact error only with ?facultyID=XXX
removed from the error message's url.
My implementation of the latter is here.