954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Passing User Agent with DOM

How would I go about passing a user agent when requesting an external xml feed from a 3rd party web service. Need to pass the user agent or else the feed produces an error. I am using DOM

<?php
$request1 = 'http://www.abc123.com/webservice/this.xml';

$requestIT1 = $request1;
$response1 = new DOMDocument();
$response1->load($requestIT1);
?>

Thanks in advance!

lonestar23
Light Poster
44 posts since Mar 2008
Reputation Points: 20
Solved Threads: 0
 

How would I go about passing a user agent when requesting an external xml feed from a 3rd party web service. Need to pass the user agent or else the feed produces an error. I am using DOM

<?php $request1 = 'http://www.abc123.com/webservice/this.xml';

$requestIT1 = $request1; $response1 = new DOMDocument(); $response1->load($requestIT1); ?>

Thanks in advance!

Google is your friend, 2nd result. http://www.php.net/manual/en/domdocument.load.php#91384

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

Final Solution which seems to work so far:

<?php
//USER AGENT FIX	 
$opts = array(
    'http' => array(
        'user_agent' => 'SearchClash/1.0',
    )
);   

$requestIT = $curl0;
$response = new DOMDocument();
//SEND USER AGENT 
$context = stream_context_create($opts);
libxml_set_streams_context($context);
$response->load($requestIT);
?>

Thanks for all the help!

lonestar23
Light Poster
44 posts since Mar 2008
Reputation Points: 20
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: