php Tutorials
Creating An RSS Feed With PHP And MySQL
Retrieving XML With Curl and SimpleXML
Using curl to Query Remote Servers
MySQL Basics
PHP mySQL Voting Booth
File Download Security
PHP Fundamentals

Retrieving XML With Curl and SimpleXML

Using curl

   function curlRequest() {

       if ($urlstring==-1) {
           echo "Couldn't Build Parameter String<br>"."n";
       curl_setopt($ch, CURLOPT_URL, $this->URL.$this->XMLRequest);
       curl_setopt($ch, CURLOPT_TIMEOUT, 180);
       curl_setopt($ch, CURLOPT_HEADER, 0);
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($ch, CURLOPT_POST, 1);
       curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);


This function handles the actual pulling of the data from the remote server with curl. We start by calling the buildCurlParamString() function and getting our POST data ready. Then we use curl_init() to initialize the curl handler and curl_setopt() to prepare curl. Notice we're using the class variables $this->URL and $this->XMLRequest, those will be set when we initialize our class and retrieve data. The data is pulled and returned to the calling function.

   function getFeed() {

       if ($rawData!=-1) {

The last function in the curl class is the function that will get called from outside this class. Notice it stores the data in a class variable, that's because we're going to extend this class with our SimpleXML class.

Retrieving Data <<  1 2 3 4 5  >> Finally SimpleXML
New Content