Bitrix Site Manager

QueryGetData

string
QueryGetData(
  string site,
  int port,
  string page,
  string query,
  int &error_number,
  string &error_text,
  string http_method = "GET",
  string site_prefix = ""
)

The function QueryGetData queries the specified web address using the HTTP protocol. Returns the server response body without header. If an error occurres, the function returns an empty string and set parameters error_number and error_text.

Parameters

ParameterDescription
site Address of the site to query.
port Port number. Usually 80.
page Path to the requested page.
query String with the query parameters in the common format.
error_number Reference to a variable that receives the error number on failure.
error_text Reference to a variable that receives the error description on failure.
http_method Method to use for querying the remote server. The following values are possible:
  • "GET"
  • "POST"
Optional; GET by default.
site_prefix Site address prefix for work through SSL or TLS. The following values are possible:
  • ""
  • "ssl://"
  • "tls://"
Optional, the default value is "" which means standard connection.

Note
Your hosting may not support non-standard connections.

Example



<?
// Query for currency exchange rates from www.cbr.ru on 18.01.2005
$strQueryText = QueryGetData(
	"www.cbr.ru", 
	80, 
	"/scripts/XML_daily.asp", 
	"date_req=18.01.2005", 
	$error_number, 
	$error_text
	);
if (strlen($strQueryText)<=0)
{
   echo "Query error!";
   if (intval($error_number)>0 || strlen($error_text)>0)
      echo ": (".$error_number.") ".$error_text;
   echo ". ";
}
else
{
   echo htmlspecialchars($strQueryText);
}
?>