本文整理汇总了PHP中CHTTP::SetAuthBasic方法的典型用法代码示例。如果您正苦于以下问题:PHP CHTTP::SetAuthBasic方法的具体用法?PHP CHTTP::SetAuthBasic怎么用?PHP CHTTP::SetAuthBasic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHTTP
的用法示例。
在下文中一共展示了CHTTP::SetAuthBasic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ShowError
break;
default:
ShowError(GetMessage("USER_AUTH_ERROR"));
return;
}
if (!$arResult["RESULT"]['ERROR']) {
$arSoapRequest = new CSOAPRequest($arSoapMethod, $arParams["PR_NAMESPACE"], $arSoapParams);
$request_body = $arSoapRequest->payload();
if (!$isUTF) {
$request_body = $APPLICATION->ConvertCharset($request_body, SITE_CHARSET, "UTF-8");
$arSoapMethod = $APPLICATION->ConvertCharset($arSoapMethod, SITE_CHARSET, "UTF-8");
}
$req = new CHTTP();
$arUrl = $req->ParseURL($arWebServiceUrl);
$arUrl["port"] = $arPort;
$req->SetAuthBasic($arLogin, $arPassword);
$req->user_agent = "BITRIX SOAP Client";
$req->http_timeout = $arTimeout;
$req->additional_headers['SOAPAction'] = $arParams["PR_NAMESPACE"] . $arSoapMethod;
$result = $req->Query("POST", $arUrl["host"], $arUrl["port"], $arUrl["path"], $request_body, $arUrl["proto"], "text/xml; charset=utf-8");
if (!$req->errstr) {
if ($req->status == 401) {
$arResult["RESULT"]['ERROR'] = GetMessage("AUTH_ERROR");
} else {
preg_match("/^<soap:Envelope.*>/i", $req->result, $preg);
if (empty($preg) || $req->status != "200") {
$arResult["RESULT"]['ERROR'] = GetMessage("WRONG_RESPONSE");
}
}
} else {
$arResult["RESULT"]['ERROR'] = $req->errstr;
示例2:
$_REQUEST['server']=$_REQUEST['current_path'];
if ($_REQUEST['server'])
setcookie("DV_SERVER", $_REQUEST['server'],0);
/*$_REQUEST['current_path']=trim($_REQUEST['current_path'],'/');
$_REQUEST['root']=trim($_REQUEST['root'],'/');
$_REQUEST['server']=trim($_REQUEST['server'],'/');*/
}
if (@$_REQUEST['mode']=='exchange')
{
$data=CUtil::JsObjectToPhp($_REQUEST['data']);
$req=new CHTTP;
$req->SetAuthBasic($data['login'],$data['pass']);
$URL=$data['url'];
if (!$data['phpsessid'])
$URL.='?mode=checkauth&type=catalog';
else
{
$URL.='?mode=import&type=catalog&filename='.$data['filename'];
$req->additional_headers['Cookie'] = 'PHPSESSID='.$data['phpsessid'].';';
}
$arUrl=$req->ParseURL($URL);
$req->Query('GET',$arUrl['host'],$arUrl['port'],$arUrl['path_query']);
$body=explode("\n",$req->result);
if (count($body)>1)
示例3: LoadFile
public function LoadFile($listName, $arParams)
{
if ($arParams['URL']) {
// hack!
$URL = str_replace(array('%3A', '%2F'), array(':', '/'), rawurlencode($GLOBALS['APPLICATION']->ConvertCharset(urldecode($arParams['URL']), LANG_CHARSET, 'utf-8')));
$CLIENT = new CHTTP();
$res = false;
if ($this->arConnectionParams['user']) {
$CLIENT->SetAuthBasic($this->arConnectionParams['user'], $this->arConnectionParams['pass']);
}
if ($file_contents = $CLIENT->Get($URL)) {
$point_pos = strrpos($URL, '.');
$ext = '';
$new_filename = md5($URL) . ($point_pos > 0 ? substr($URL, $point_pos) : '');
$new_filepath = $_SERVER['DOCUMENT_ROOT'] . $this->ATTACHMENTS_PATH . '/' . substr($new_filename, 0, 2) . '/' . $new_filename;
CheckDirPath($new_filepath);
$fp = fopen($new_filepath, 'wb');
fwrite($fp, $file_contents);
fclose($fp);
$res = CFile::MakeFileArray($new_filepath);
}
}
unset($CLIENT);
return $res;
}
示例4: CHTTP
break;
case 'test':
if (!check_bitrix_sessid()) {
return;
}
$sp_server = $_REQUEST['sp_server'];
$sp_user = $_REQUEST['sp_user'];
$sp_pass = $_REQUEST['sp_pass'];
$arResult['SERVER'] = 0;
$arResult['AUTH'] = 0;
if ($sp_server && $sp_server != 'http://' && ($URL = CHTTP::ParseURL($sp_server))) {
if ($URL['host'] && $URL['scheme'] == 'http') {
$ob = new CHTTP();
$ob->setFollowRedirect(false);
if ($sp_user) {
$ob->SetAuthBasic($sp_user, $sp_pass);
}
if ($ob->Get($sp_server) !== false) {
if ($ob->status == 200 || $ob->status == 302 || $ob->status == 401) {
$arResult['SERVER'] = 1;
if ($ob->status != 401) {
$arResult['AUTH'] = 1;
}
}
}
}
}
$this->IncludeComponentTemplate('form_server_test');
break;
}
return;