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('');
}
}

php 调用 java 接口的更多相关文章

  1. C#调用JAVA接口WSSE方式用WebClient方式

    C#读取JAVA的WSSE接口的调用代码: 用webclient 方式: /// <summary> /// 调用java cxf ws_security加密的服务wcf客户端对应的加密类 ...

  2. android NDK 实用学习(五)-c++端调用java接口

    1,阅读此文章前请阅读前面文章,以免阅读出现障碍: android NDK 实用学习(一)-获取java端类及其类变量 android NDK 实用学习(二)-java端对象成员赋值和获取对象成员值 ...

  3. C#调用java接口报“Fault occurred while processing”异常问题

    服务在通常项目中总是要用到的C#的webservice.wcf,还有第三方的,比如java服务.一般来说调用都不会有什么问题,因为服务的标准都是一样的.要注意的就是:1.参数个数匹配:2.参数类型和返 ...

  4. 对接第三方平台JAVA接口问题推送和解决

    前言 本节所讲为实际项目中与第三方对接出现的问题最后还是靠老大解决了问题以此作为备忘录,本篇分为三小节,一小节解析Java加密接口数据,二小节解析XML文件需注意问题,最后一节则是请求Java Soa ...

  5. C#调用Java WebService int、DateTime等类型值接收到为空

    今天在调用Java接口时,有个int类型的值很明确的传了1,但接口一直返回没有接收到这个值. 解决方法: 引用接口时,VS会自动生成一个类,类中对于非string类型的字段会生成一个xxSpecifi ...

  6. java接口调用——webservice就是一个RPC而已

    很多新手一听到接口就蒙逼,不知道接口是什么!其实接口就是RPC,通过远程访问别的程序提供的方法,然后获得该方法执行的接口,而不需要在本地执行该方法.就是本地方法调用的升级版而已,我明天会上一篇如何通过 ...

  7. 规则引擎集成接口(七)规则引擎调用Java类

    规则引擎调用Java类 通过myEclipse编写一个简单工程,其中方法是两数相加等到结果,既结果1=输入值1+输入值2.实现规则调用外部接口的方法有三种. 1:接口实例:在myEclipse中制作一 ...

  8. Java调用webservice接口方法

                             java调用webservice接口   webservice的 发布一般都是使用WSDL(web service descriptive langu ...

  9. OpenCV4Android开发之旅(一)----OpenCV2.4简介及 app通过Java接口调用OpenCV的示例

    转自:  http://blog.csdn.net/yanzi1225627/article/details/16917961 开发环境:windows+ADT Bundle+CDT+OpenCV-2 ...

随机推荐

  1. PHP 单例模式代码片段

    <?php error_reporting(E_ALL | E_STRICT); class single{ public $hash; static protected $ins = null ...

  2. Python函数1

    Python 函数命令的使用 想想我们之前数学中学到的函数,首先我们需要定义一个函数,例如f(x)=x, 当x输入任意数的时候,f(x)都能输出和x相等的数值. 那么在Python中是如何实现的呢? ...

  3. kuaisupaixu

    #include<stdio.h> void quiksort(int a[],int low,int high) {  int i = low;     int j = high;    ...

  4. Spring IoC反转控制的快速入门

    * 下载Spring最新开发包 * 复制Spring开发jar包到工程 * 理解IoC反转控制和DI依赖注入 * 编写Spring核心配置文件 * 在程序中读取Spring配置文件,通过Spring框 ...

  5. svn 入门

    SVN版本:1.5 及更新版本 名词说明: WC:Working Copy 你的工作区 Versioned:受控的:受版本控制的 SVN是什么? SVN是开源的版本控制系统. 比CVS更多的特性.一个 ...

  6. spark mllib 之线性回归

    public static void main(String[] args) { SparkConf sparkConf = new SparkConf() .setAppName("Reg ...

  7. 高级 Synth

    http://www.ibm.com/developerworks/cn/java/j-synth/

  8. 使用Reveal

    添加Reveal.framework,设置Other link flags 添加Debug为 -ObjC,添加 libz 库 这里介绍 Reveal UI 分析工具的简单使用,至于使用他分析手机 Ap ...

  9. 对于HIVE架构的理解

    1.Hive  能做什么,与 MapReduce 相比优势在哪里 关于hive这个工具,hive学习成本低,入手快,对于熟悉sql语法的人来说,操作简单,熟悉. 2.为什么说 Hive 是 Hadoo ...

  10. C#5.0 .net 4.5示例

    //filename: MathOperations.cs using System; using System.Collections.Generic; using System.Linq; usi ...