码迷,mamicode.com
首页 > Web开发 > 详细

Datasnap http用户验证

时间:2015-09-25 11:09:38      阅读:330      评论:0      收藏:0      [点我收藏+]

标签:

<?php
echo "login info:";
$url = "http://192.168.3.9:8081/datasnap/rest/TPrjMis/js/1/2";
$param = array(‘content‘=>‘I am sulin‘);
$_SESSION["uname"]="admin";
$_SESSION["pass"]="uv";
$userinfo=$_SESSION["uname"].":".$_SESSION["pass"];

$auth = sprintf(‘Authorization: Basic %s‘, base64_encode($userinfo)); // 加入这句

$opt = array(
‘http‘ => array(
‘method‘ => ‘GET‘,
‘header‘ => "content-type:application/x-www-form-urlencoded\r\n".$auth."\r\n", // 把$auth加入到header
‘content‘ => http_build_query($param)
)
);

$context = stream_context_create($opt);

$ret = file_get_contents($url, false, $context);
echo $ret;


?>

Datasnap http用户验证

标签:

原文地址:http://www.cnblogs.com/HuiLove/p/4837322.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!