• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

php 调用 java 接口 - xiangjune

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

php 调用 java 接口

2016-03-03 13:50  xiangjune  阅读(6392)  评论(0编辑  收藏  举报

php 需要开启 curl模块

 

/*
* HTTP 请求函数封装
*/
function http_request_cloudzone($url, $data){
//var_dump($url."test");
if(!$url){
return "";
}

$ch = curl_init ();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); //禁用证书
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_HEADER, 0); //头文件信息做数据流输出
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt ($ch, CURLOPT_POST, 1); //启用POST提交
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$output = curl_exec ($ch);
curl_close ($ch);

return json_decode($output, true);
}

// 请求获取登陆用户信息
// http://localhost/wiki/test.php?userId=71D68F2D8C780B6D785F392ED024B701359CBF3CCBDB25D5&appId=CNGDLG0200000000000&interfacesURL=http://192.168.102.114/cloudzone/
// {\"appId\":\"CNGDLG0200000000000\", \"userId\":\"71D68F2D8C780B6D785F392ED024B701359CBF3CCBDB25D5\"}"

// rsp { ["appInfo"]=> array(3) { ["appId"]=> string(19) "CNGDLG0200000000000" ["webUrl"]=> string(36) "http://192.168.113.127/wiki/test.php" ["webUrlWan"]=> string(36) "http://192.168.113.127/wiki/test.php" } ["serverResult"]=> array(2) { ["resultCode"]=> int(0) ["resultMessage"]=> string(6) "成功" } ["teacherClassList"]=> array(0) { } ["token"]=> string(112) "183cfa43aa68d5b3c393753e173e914626b859e14ee40df68ba289324d8706d7679be1e96c2a3a2e333d6972bd521b9b4fb45e0d6dd1e2ee" ["userInfo"]=> array(11) { ["encryptedUserId"]=> string(48) "71D68F2D8C780B6D785F392ED024B701359CBF3CCBDB25D5" ["gender"]=> string(0) "" ["lastModifyTime"]=> string(19) "2016-02-29 09:49:02" ["loginName"]=> string(4) "test" ["schoolId"]=> string(19) "CNGDLG0600000000001" ["schoolName"]=> string(6) "学校" ["schoolSection"]=> string(14) "PRIMARY_SCHOOL" ["staticPassword"]=> string(16) "a83a68c6e9967731" ["userAccount"]=> string(19) "CNGDLG0600000000025" ["userName"]=> string(4) "test" ["userType"]=> string(1) "2" } ["xmppInfo"]=> array(3) { ["xmppHeartbeatPort"]=> string(4) "9090" ["xmppIp"]=> string(22) "http://192.168.102.114" ["xmppServer"]=> string(34) "http://http://192.168.102.114:9090" } }
// 新增TW教育云鉴权同步登陆入口方法
function dotwauthentication(){

if(!$this->get[\'2\'] || !$this->get[\'3\'] || !$this->get[\'4\']){
$this->header("");
}
$url = $this->get[\'2\'];
$data[\'userId\'] = $this->get[\'3\'];
$data[\'appId\'] = $this->get[\'4\'];
$data_json = json_encode($data);
$url = $url."/ClientApi/getAuthenticationInfo";

$output_json = $this->http_request_cloudzone($url, $data_json);

if($output_json){
$rsp_code = $output_json["serverResult"]["resultCode"];

if($rsp_code == 0){
// 请求成功
$twuserid= $output_json["userInfo"]["userAccount"];
$twuserpwd= $output_json["userInfo"]["staticPassword"];
$twusername= $output_json["userInfo"]["userName"];

$des_java_c = new DES_JAVA();
$twuserpwd= $des_java_c->decrypt($twuserpwd);

$this->dotwsysuser($twusername, $twuserid, $twuserpwd);
}else{
//请求失败
$this->header(\'\');
}
}else{
//请求失败
$this->header(\'\');
}
}


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP中调用JAVA发布时间:2022-07-10
下一篇:
PHP通过php-java-bridge调用JAVA的jar包里class类发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap