?
Solved

GET external data  using PHP

Posted on 2007-08-08
6
Medium Priority
?
1,145 Views
Last Modified: 2013-12-12
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
0
Comment
Question by:bborner
  • 3
4 Comments
 
LVL 1

Expert Comment

by:Blarger
ID: 19658442
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.
0
 
LVL 1

Expert Comment

by:Blarger
ID: 19658445
from an external source*
0
 

Author Comment

by:bborner
ID: 19658679
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>
0
 
LVL 1

Accepted Solution

by:
Blarger earned 2000 total points
ID: 19658776
PHP concentration operator is a ".". So it should look something like:

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question