Curl and PHP- Need a php script to execute simple get for xml data

Posted on 2006-05-16
Last Modified: 2010-08-05
I am trying to use PHP to excecute a curl command to get xml data from my root vault,  The documentation for the curl command is here:  

Something like this:

download everything ending on a given date:

curl -k -u YOURUSERNAME ""

I need the PHP script to excecute this function.  Also I am looking for a way to format my XML data using the DOM module so I can format with css and html etc.
Question by:admin_mjschiff
    LVL 49

    Expert Comment

    You can use ofcourse the curl_init() etc functions.

    An alternative might however be to use:

    $xml = file_get_contents('');

    LVL 4

    Accepted Solution

    try this

    function curl_request($url,$request)
          if (function_exists('curl_init')) {
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);            
                $airborne_response = curl_exec($ch);
          } else {
                $fp = fopen($url, "r");
                      $result = fgets($fp, 500);
          return $airborne_response;

    $xml="some xml request";


    echo $response;exit;

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now