Jump to content

Trying to grab xml data through a url


andy1212

Recommended Posts

$url = "http://www.example.com/path/to/page?"; // with the question mark
$get = array("key 1" => "value 1", "key 2" => "value 2", "key 3" => "value 3" /* ... */);
$xml = new SimpleXMLElement($url . http_build_query($get), 0, true);
From there you have a SimpleXMLElement that you can do pretty much anything you want with. What do you want to do? What kind of XML are you getting back?

its not http:// its https:// and ssl secured so I need to handshake or authenticate with the page before grabbing the xml data and bringing it back to me webpage. The url looks like this,

 

I have the url setup like this,

$xml = '
weight_system="IMPERIAL" shipper_number="000222000" destination_postal_code="'.$data5['zip'].'" service_type="1"
';


$xml2 = '
total_pieces="'.$value.'" total_weight="'.$weight.'"
'; 


$token = 'token'; 
$base_url = 'https://www.shippingco.com/XML/RatingXML.jsp'; 


$request_url = $base_url . '?' . http_build_query(array(
     'shipment' => '<shipment ' . $xml . '><total ' . $xml2 . '/></shipment>',
       'token' => $token
));

I have an RSA key, SSL cert, CA bundle and password and need to use that information to authenticate with the url to grab the xml data. and xml example

 

 

<rating xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.shippingco.com/XML/rating.xsd">
<rate weight="5.0" weight_unit="lb" zone="3" transit_time="1" transit_time_guaranteed="false" estimated_delivery_date="2013-07-26" base_charge="11.05" freight_charge="11.05"residential_address_charge="2.75" net_charge="13.80" fuel_surcharge_rate="15.8" fuel_surcharge="1.75" subtotal_charge="15.55" on_hst_charge="2.02" total_charge="17.57"/>
</rating>

So how would I go about doing that?

Nope. What have you discovered in the last 24 hours?

 

its not http:// its https:// and ssl secured so I need to handshake or authenticate with the page before grabbing the xml data and bringing it back to me webpage

If you want to actually built the TCP/IP packets yourself then sure, go ahead and climb that mountain. But the rest of us don't mind letting PHP and our operating system do that work for us.

 

Or to be more blunt, are you saying

file_get_contents($request_url)
does not work?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.