2014-03-05 22 views
0

我有一个映像,它实际上是一个动态生成的图形,托管在另一个服务器上(我无权访问)。该网站在显示图像之前需要进行基本认证。如果您尚未登录,则会显示一个登录框(基本身份验证,而不是表单身份验证)。登录凭证总是相同的 - 根据用户登录到SharePoint的情况,它们不会有所不同。在需要基本身份验证的SharePoint中显示图像

图像可以从https://site.com/image.php?id=1336

我想嵌入在SharePoint这一形象进行访问。它不需要直接嵌入。我愿意编写一个简单的页面,将它托管在SharePoint外部,并且如果它更有意义(尽管一个嵌入式解决方案通常更容易管理),那么就会嵌入它。该解决方案需要与大多数现代浏览器一起工作(例如,您可以在Chrome中使用URL https://user:[email protected]/image.php?id=1336,但它不适用于IE)。

我已经做了大量的搜索工作,但还没有找到适合需求的解决方案(并且我有大脑的力量可以遵循)。

任何援助将不胜感激。使用

+0

你考虑这个http://camelotphptools.codeplex.com/? –

回答

0

cUrl作者:这将是非常简单的:

$host = 'http://path-to-your-site.com/image.php?id=1336'; //site 
$username = 'username'; //basic auth username 
$password = 'password'; //basic auth password 
$process = curl_init($host); //initiate the host request 
curl_setopt($process, CURLOPT_HTTPHEADER, 'Content-Type: image/png'); //png? 
curl_setopt($process, CURLOPT_HEADER, 1); // 1 for incldue header in output, 0 for not 
curl_setopt($process, CURLOPT_USERPWD, $username . ":" . $password); //the auth request 
curl_setopt($process, CURLOPT_TIMEOUT, 30); //how long will we wait 
curl_setopt($process, CURLOPT_POST, 0); //not a post request 
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); //return as a string or print immediately? 
$return = curl_exec($process); //the returned image 
curl_close($process); //end your curl request 
//do something with $return