我正在通过xml url来获取数据。
$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.');
}
}
然后我在第36行使用以下php方法,如我的php警告
中所述$xml_response = simplexml_load_string( $xml_resp );
我唯一的问题是我正在关注php警告:
PHP已弃用:不推荐使用以“#”开头的注释 第0行的Unknown第1行/etc/php5/cli/conf.d/ming.ini
PHP警告:simplexml_load_string():实体:第1行:解析器错误: 期望开始标记,'&lt;'找不到 第36行的/var/www/include/class.xmlcron.php
PHP警告:simplexml_load_string():常规错误
令牌为 在第36行的/var/www/include/class.xmlcron.php中未被识别PHP警告:simplexml_load_string():^ in 第36行的/var/www/include/class.xmlcron.php
PHP警告:simplexml_load_string():实体:第1行:解析器错误: 期望开始标记,'&lt;'找不到 第36行的/var/www/include/class.xmlcron.php
PHP警告:simplexml_load_string():常规错误
令牌为 在第36行的/var/www/include/class.xmlcron.php中未被识别PHP警告:simplexml_load_string():^ in 第36行的/var/www/include/class.xmlcron.php
请让我知道我在这里做错了什么。