Link to home
Start Free TrialLog in
Avatar of bborner
bbornerFlag for United States of America

asked on

GET external data using PHP

I need to access data from an external website for display on a FreeBsd server ..
I was given the following code as an example ...  but how is this embedded in a PHP procedure?

Example:
HTTP GET
The following is a sample HTTP GET request and response. The placeholders shown need to be replaced with actual values.

GET /ws/q88ws.asmx/GetFleetList_XmlString?AuthorizationString=string&FleetName=string HTTP/1.1
Host: www.q88.com

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0"?>
xml
HTTP POST
The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.

POST /ws/q88ws.asmx/GetFleetList_XmlString HTTP/1.1
Host: www.q88.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length

AuthorizationString=string&FleetName=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0"?>
xml

Thanks
Avatar of Blarger
Blarger

Those are actually the response headers from a web server.

You can use the PHP function file to get data from an source
http://www.php.net/file

There are plenty of examples there.
from an external source*
Avatar of bborner

ASKER

Not sure what I get when this is returned nor the syntax to use to perform the get defined below.
The URL you gave me http://www.php.net/file  was helpful but still don't know which function to use.

I used a simple:  $lines = file("http://www.q88.com/WS/Q88WS.asmx/GetQ88?AuthorizationString=" + "XXXXXXX" + "&VesselName=" + "Chembulk Westport");

This request failed possibly due to the syntax used above to insert the authorization string and vessel name .. (i can't include the actual authorization string for security reasons)


This was btw the Soap 1.2 code given by the provider (Q88) as an example for accessing their data.
POST /ws/q88ws.asmx HTTP/1.1
Host: www.q88.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetFleetList_XmlString xmlns="http://q88.com/webservices/">
      <AuthorizationString>string</AuthorizationString>
      <FleetName>string</FleetName>
    </GetFleetList_XmlString>
  </soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetFleetList_XmlStringResponse xmlns="http://q88.com/webservices/">
      <GetFleetList_XmlStringResult>xml</GetFleetList_XmlStringResult>
    </GetFleetList_XmlStringResponse>
  </soap12:Body>
</soap12:Envelope>
ASKER CERTIFIED SOLUTION
Avatar of Blarger
Blarger

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial