Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2006-05-16
Medium Priority
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: http://vaults.root.net/api/docs 

Something like this:

download everything ending on a given date:

curl -k -u YOURUSERNAME "https://root.net/people/THEIRUSERNAME/module/dlraw?end=YYYY-MM-DD"

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

ID: 16696746
You can use ofcourse the curl_init() etc functions.

An alternative might however be to use:

$xml = file_get_contents('https://username@root.net/people/THEIRUSERNAME/module/dlraw?end=YYYY-MM-DD');


Accepted Solution

anilande earned 500 total points
ID: 16740455
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 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