How to HTTP GET while sending vars and retrieve XML output using PHP

madness

New Member
I'm trying to use this API: www.cpsc.gov/cpscpub/prerel/api.htmlDocumentation: www.cpsc.gov/cpscpub/prerel/requirements.pdfHere is the location calls are to be sent, which also includes sample code snippets: http://www.cpsc.gov/cgibin/CPSCUpcWS/CPSCUpcSvc.asmxThe getRecallByWord function should return XML data.Here's a preformed URL for getting the data (note, have to use https according to doc):www.cpsc.gov/cgibin/CPSCUpcWS/CPSCUpcSvc.asmx/getRecallByWord?message1=3M&password=password&userId=userIdIn the documentation there is a note that no specific username or password is required (anything will work)I've tried fopen, file_get_contents, and http_get (although the last one didn't work since extension isn't installed).$result = fopen("https://www.cpsc.gov/cgibin/CPSCUpcWS/CPSCUpcSvc.asmx/getRecallByWord?message1=3M&password=password&userID=userId",r);
print $result;
print "done";
$response = file_get_contents("https://www.cpsc.gov/cgibin/CPSCUpcWS/CPSCUpcSvc.asmx/getRecallByWord?message1=3M&password=password&userID=userId");
print $response;
print "done"; Output:
Resource id #3done doneallow_url_fopen is On
 
Back
Top