有人能给我解释一下为什么这个私有bitbucket存储库的授权功能在我的本地机器(运行PHP版本5.3.17)上工作,但在我的远程服务器(运行PHP版本5.3.20)上不授权吗?
我本身并没有收到错误--我只是从bitbucket得到了一个“禁止的”响应。但在我的本地服务器上运行时,一切都运行得很好。
function bitBucketConnect($url){
global $bitPassword;
global $bitUsername;
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$bitUsername:$bitPassword")
)
));
// Make the request
return file_get_contents($url, false, $context);
}发布于 2013-02-08 21:57:16
您的代理将响应需要身份验证。您可能会挠头并想“但是我提供了身份验证!”
问题是“header”值只适用于http连接。因此,要在代理上进行身份验证,首先必须从HTTP中提取一个文件,然后上下文才能在FTP上有效使用。
<?php
$opts = array('ftp' => array(
'proxy' => 'tcp://vbinprst10:8080',
'request_fulluri'=>true,
'header' => array(
"Proxy-Authorization: Basic $auth"
)
),
'http' => array(
'proxy' => 'tcp://vbinprst10:8080',
'request_fulluri'=>true,
'header' => array(
"Proxy-Authorization: Basic $auth"
)
)
);
$context = stream_context_create($opts);
$s = file_get_contents("http://www.example.com",false,$context);
$s = file_get_contents("ftp://anonymous:anonymous@ftp.example.org",false,$context);
?> https://stackoverflow.com/questions/14591601
复制相似问题