如何用代码实现聚合接口对接
发表于:2024-09-29 作者:千家信息网编辑
千家信息网最后更新 2024年09月29日,本篇内容介绍了"如何用代码实现聚合接口对接"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
千家信息网最后更新 2024年09月29日如何用代码实现聚合接口对接
本篇内容介绍了"如何用代码实现聚合接口对接"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
'appkey', 'flow'=>'appkey', 'sinopec'=>'appkey', ); public $openid = 'JH160141dd01f07b3149d99dad44802431'; public $appkey = ''; /** * juheModel constructor. * @param string $type tel 话费 flow 流量 sinopec 油卡 */ public function __construct($type) { switch($type){ case 'tel': $this ->appkey = $this ->appkey_config['tel']; break; case 'flow': $this ->appkey = $this ->appkey_config['flow']; break; case 'sinopec': $this ->appkey = $this ->appkey_config['sinopec']; break; } } /** * 【油卡】加油卡充值 * @param $proid * @param $cardnum * @param $orderid * @param $game_userid * @param $gasCardTel * @param $gasCardName * @param $chargeType * @return mixed */ public function order($proid,$cardnum,$orderid,$game_userid,$gasCardTel,$gasCardName,$chargeType) { $url = "http://op.juhe.cn/ofpay/sinopec/onlineorder"; $newkey = $this->openid.$this->appkey.$proid.$cardnum.$game_userid.$orderid; $sign= md5($newkey); $params = array( "proid" => $proid,//产品id:10000(中石化50元加油卡)、10001(中石化100元加油卡)、10003(中石化500元加油卡)、10004(中石化1000元加油卡)、10007(中石化任意金额充值)、10008(中石油任意金额充值) "cardnum" => $cardnum,//充值数量 任意充 (整数(元)),其余面值固定值为1 "orderid" => $orderid,//商家订单号,8-32位字母数字组合 "game_userid" => $game_userid,//加油卡卡号,中石化:以100011开头的卡号、中石油:以9开头的卡号 "gasCardTel" => $gasCardTel,//持卡人手机号码 "gasCardName" => $gasCardName,//持卡人姓名 "chargeType" => $chargeType,//加油卡类型 (1:中石化、2:中石油;默认为1) "key" => $this->appkey,//应用APPKEY(应用详细页查询) "sign" => $sign,//校验值,md5(OpenID+key+proid+cardnum+game_userid+orderid),OpenID在个人中心查询 ); $content = $this->juhecurl($url, $params); $result = json_decode($content, true); return $result; } /** * 【油卡】油卡查询订单状态 * @param $orderid * @return mixed */ public function ordersta($orderid) { $url = "http://op.juhe.cn/ofpay/sinopec/ordersta"; $params = array( "orderid" => $orderid,//商家订单号,8-32位字母数字组合 "key" => $this->appkey,//应用APPKEY(应用详细页查询) ); $content = $this->juhecurl($url, $params); $result = json_decode($content, true); return $result; } /** * 【流量】全部流量套餐列表 * @return mixed */ public function flowlist() { //************1.全部流量套餐列表************ $url = "http://v.juhe.cn/flow/list"; $params = array( "key" => $this->appkey,//应用APPKEY(应用详细页查询) ); $paramstring = http_build_query($params); $content = $this->juhecurl($url,$paramstring); $result = json_decode($content,true); return $result; } /** * 【流量】检测号码支付的流量套餐 * @param $phone * @return mixed */ public function telcheck($phone) { //************2.检测号码支持的流量套餐************ $url = "http://v.juhe.cn/flow/telcheck"; $params = array( "phone" => $phone,//要查询的手机号码 "key" => $this->appkey,//应用APPKEY(应用详细页查询) ); $paramstring = http_build_query($params); $content = $this->juhecurl($url,$paramstring); $result = json_decode($content,true); return $result; //************************************************** } /** * 【流量】检测号码购买的流量是否存在 * @param $phone * @param $price * @return bool */ public function telpricecheck($phone,$price) { //************2.检测号码支持的流量套餐************ $url = "http://v.juhe.cn/flow/telcheck"; $params = array( "phone" => $phone,//要查询的手机号码 "key" => $this->appkey,//应用APPKEY(应用详细页查询) ); $paramstring = http_build_query($params); $content = $this->juhecurl($url,$paramstring); $result = json_decode($content,true); if($result){ if($result['error_code']=='0'){ $product=$result['result'][0]; $flows=$result['result'][0]['flows']; if($flows && count($flows)>0) { foreach ($flows as $flow) { if($flow['p']==$price) { $product['item']=$flow; return $product; } } } return false; }else{ return false; } }else{ return false; } //************************************************** } /** * 【流量】提交流量充值 * @param $phone * @param $pid * @param $orderid * @return mixed */ public function recharge($phone,$pid,$orderid) { //************3.提交流量充值************ $newkey = $this->openid.$this->appkey.$phone.$pid.$orderid; $sign= md5($newkey); $url = "http://v.juhe.cn/flow/recharge"; $params = array( "phone" => $phone,//需要充值流量的手机号码 "pid" => $pid,//流量套餐ID "orderid" => $orderid,//自定义订单号,8-32字母数字组合 "key" => $this->appkey,//应用APPKEY(应用详细页查询) "sign" => $sign,//校验值,md5(OpenID+key+phone+pid+orderid),结果转为小写 ); $paramstring = http_build_query($params); $content = $this->juhecurl($url,$paramstring); $result = json_decode($content,true); return $result; //************************************************** } /** * 【流量】订单状态查询 * @param $orderid * @return mixed */ public function orderstaflow($orderid) { //************4.订单状态查询************ $url = "http://v.juhe.cn/flow/ordersta"; $params = array( "orderid" => $orderid,//商家订单号,8-32位字母数字组合,由您自己生成 "key" => $this ->appkey, //应用APPKEY(应用详细页查询) ); $paramstring = http_build_query($params); $content = $this->juhecurl($url,$paramstring); $result = json_decode($content,true); return $result; //************************************************** } /** * 【话费】检测手机号是否能充值 * @param $phone * @param $cardnum * @return mixed */ public function telcheckmobile($phone,$cardnum) { //************1.检测手机号码是否能充值************ $url = "http://op.juhe.cn/ofpay/mobile/telcheck"; $params = array( "phoneno" => $phone,//要查询的手机号码 "cardnum" => $cardnum,//充值金额,目前可选:10、20、30、50、100、300 "key" => $this ->appkey //应用APPKEY(应用详细页查询) ); $paramstring = http_build_query($params); $content = $this->juhecurl($url,$paramstring); $result = json_decode($content,true); return $result; //************************************************** } /** * 【话费】根据手机号和面值查询商品 * @param $phone * @param $cardnum * @return mixed */ public function telquery($phone,$cardnum) { //************2.根据手机号和面值查询商品************ $url = "http://op.juhe.cn/ofpay/mobile/telquery"; $params = array( "phoneno" => $phone,//要查询的手机号码 "cardnum" => $cardnum,//充值金额,目前可选:10、20、30、50、100、300 "key" => $this ->appkey //应用APPKEY(应用详细页查询) ); $paramstring = http_build_query($params); $content = $this->juhecurl($url,$paramstring); $result = json_decode($content,true); return $result; //************************************************** } /** * 【话费】手机直充接口 * @param $phone * @param $cardnum * @param $orderid * @return mixed */ public function onlineorder($phone,$cardnum,$orderid) { //************3.手机直充接口************ $url = "http://op.juhe.cn/ofpay/mobile/onlineorder"; $newkey = $this->openid.$this->appkey.$phone.$cardnum.$orderid; $sign= md5($newkey); $params = array( "phoneno" => $phone,//要查询的手机号码 "cardnum" => $cardnum,//充值金额,目前可选:10、20、30、50、100、300 "orderid" => $orderid,//商家订单号,8-32位字母数字组合,由您自己生成 "key" => $this ->appkey, //应用APPKEY(应用详细页查询) "sign" => $sign //校验值,md5(OpenID+key+phoneno+cardnum+orderid),OpenID在个人中心查询 ); $paramstring = http_build_query($params); $content = $this->juhecurl($url,$paramstring); $result = json_decode($content,true); return $result; //************************************************** } /** * 【话费】订单状态查询 * @param $orderid * @return mixed */ public function orderstamobile($orderid) { //************4.订单状态查询************ $url = "http://op.juhe.cn/ofpay/mobile/ordersta"; $params = array( "orderid" => $orderid,//商家订单号,8-32位字母数字组合,由您自己生成 "key" => $this ->appkey, //应用APPKEY(应用详细页查询) ); $paramstring = http_build_query($params); $content = $this->juhecurl($url,$paramstring); $result = json_decode($content,true); return $result; //************************************************** } /** * 【公共】请求接口返回内容 * @param string $url [请求的URL地址] * @param string $params [请求的参数] * @param int $ispost [是否采用POST形式] * @return string */ function juhecurl($url,$params='',$ispost=0){ $params = htmlspecialchars_decode($params); $httpInfo = array(); $ch = curl_init(); curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 ); curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 3600 ); curl_setopt( $ch, CURLOPT_TIMEOUT , 3600); curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , true); if( $ispost ) { curl_setopt( $ch , CURLOPT_POST , true ); $paramstring = http_build_query($params); curl_setopt( $ch , CURLOPT_POSTFIELDS , $paramstring ); curl_setopt( $ch , CURLOPT_URL , $url ); } else { if($params){ curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params ); }else{ curl_setopt( $ch , CURLOPT_URL , $url); } } $response = curl_exec( $ch ); logInfo($url.'-请求地址','juhe_push','JuheLog'); logInfo(json_encode($params).'-请求数据','juhe_push','JuheLog'); logInfo($response.'-返回数据','juhe_push','JuheLog'); if ($response === FALSE) { return false; } //$httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE ); //$httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) ); curl_close( $ch ); return $response; } }
"如何用代码实现聚合接口对接"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!
查询
应用
流量
手机
号码
订单
手机号码
中石
中石化
套餐
字母
数字
订单号
检测
组合
接口
商家
状态
话费
金额
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
从云服务器
代理服务数据库
软件开发大数据实验实训平台
有关网络安全的知识问题
软件开发费包括
网络安全第41条
电脑远程服务器上找不到电脑硬盘
用什么软件开发远程控制
浙江互联网大会创新科技
宜昌网络安全审计
无效会话服务器无法加入
自动化登陆设施原理网络安全
服务器内部数据管理
win7网络安全模式蓝屏
德国列车网络技术发展现状
数据库多进程扫库
用php连接数据库
诺顿网络安全专业版
西安欧鹏科技互联网公司
网络安全讲座的感言
lora+无线网络技术分析
中国家族史数据库
市场网络安全培训班
国三数据库技术 未来教育
怀旧服哪里有服务器掉线
周经理的烦恼应用软件开发公司
服务器内部数据管理
上海网络安全宣传周松江
网络安全 专题
远恒互联网科技