0

I am curling through xml url to fetch data.

$xml_resp = $this->lead_call ( $xml_url );

function lead_cal($url){
    $split_url = explode( '?', $url );
    if ( !empty( $split_url ) && count( $split_url ) == 2 )
    {
        $domain = $split_url[ 0 ];
        $params = $split_url[ 1 ];
        $split_params = explode( '&', $params );
        $encoded_values = array();
        foreach ( $split_params as $curr_param )
        {
            $split_curr_param = explode( '=', $curr_param );
            $param_name  = $split_curr_param[ 0 ];
            $param_value = $split_curr_param[ 1 ];
            $encoded_value = urlencode( $param_value );
            $encoded_values[ $param_name ] = $encoded_value;
        }

        $encoded_url = $domain;
        if ( !empty( $encoded_values ) )
        {
            $size = count( $encoded_values );
            $encoded_url .= '?';
            $index = 0;
            foreach ( $encoded_values as $key => $value )
            {
                $encoded_url .= $key . '=' . $value;
                if ( $index < $size - 1 )
                    $encoded_url .= '&';
                ++$index;
            }
        }
    }
    else
        $encoded_url = $url;


    try
    {
        $options = array(
            CURLOPT_RETURNTRANSFER => true,     // return web page
            CURLOPT_HEADER         => false,    // don't return headers
            CURLOPT_FOLLOWLOCATION => true,     // follow redirects
            CURLOPT_ENCODING       => "",       // handle all encodings
            CURLOPT_USERAGENT      => "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0", // who am i
            CURLOPT_AUTOREFERER    => true,     // set referer on redirect
            CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
            CURLOPT_TIMEOUT        => 120,      // timeout on response
            CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
            CURLOPT_SSL_VERIFYPEER => false     // Disabled SSL Cert checks
        );
        $curlHandler = curl_init($encoded_url);
        curl_setopt_array( $curlHandler, $options );

        $curlResponse = curl_exec( $curlHandler );  //comment to stop curl while debugging
        $http_status = curl_getinfo( $curlHandler, CURLINFO_HTTP_CODE );

                if ( !$curlResponse )
                    return false;

                curl_close( $curlHandler );
                return $curlResponse;
    }
    catch ( Exception $exception )
    {
            die('Cant Crawl the site this time. Please check donor address.');
    }
}

then I am using following php method on line 36 as mentioned in my php warning

$xml_response = simplexml_load_string( $xml_resp );

my only issue is i am getting following php warnings:

PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0

PHP Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in /var/www/include/class.xmlcron.php on line 36

PHP Warning: simplexml_load_string(): General Error
Token is unrecognized in /var/www/include/class.xmlcron.php on line 36

PHP Warning: simplexml_load_string(): ^ in /var/www/include/class.xmlcron.php on line 36

PHP Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in /var/www/include/class.xmlcron.php on line 36

PHP Warning: simplexml_load_string(): General Error
Token is unrecognized in /var/www/include/class.xmlcron.php on line 36

PHP Warning: simplexml_load_string(): ^ in /var/www/include/class.xmlcron.php on line 36

please let me know what i am doing wrong here.

Deepak Verma
  • 55
  • 2
  • 2
  • 7

0 Answers0