PHP的单点登录代码你可以用这个- <?php
- namespace app\index\controller;
- use think\Controller;
- class Index extends Controller
- {
- public function index()
- {
- $url = "http://localhost:48143/SSO/GetUserToken";
- $userName = "administrator";
- $password = "";//密码
- $data = "{userName:"" . $userName . "", password:"" . $password . ""}";
- var_dump($url);
- var_dump($data);
- return $this->https_request($url, $data);
- }
- public function https_request($url, $data){
- $data = array('userName' => 'administrator', 'password' => 'DXRLcwhQBiqX');
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
- 'method' => 'POST',
- 'content' => http_build_query($data)
- )
- );
- $context = stream_context_create($options);
- $result = file_get_contents($url, false, $context);
- if ($result === FALSE) {
- return $result;
- }
- var_dump($result);
- }
-
- }
复制代码
|