You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.8 KiB
80 lines
2.8 KiB
<?php
|
|
|
|
namespace app\service\pay;
|
|
|
|
use app\api\controller\Base;
|
|
|
|
require_once("security.php");
|
|
|
|
$format = "json";
|
|
$version = "2.0";
|
|
$token_session = "";
|
|
$token_secretkey = "";
|
|
$open_api_url = "";
|
|
$appid = "";
|
|
|
|
class ApiHelperoneService extends Base{
|
|
|
|
public function init($openapiurl,$appid,$session,$secretkey){
|
|
// $appid="910000198";
|
|
// $secretkey="gRAZZKiNw0UbTuF9";
|
|
$GLOBALS['appid']=$appid;
|
|
$GLOBALS['open_api_url']=$openapiurl;
|
|
$GLOBALS['token_session'] = $session;
|
|
$GLOBALS['token_secretkey'] = $secretkey;
|
|
$GLOBALS['format'] = "json";
|
|
$GLOBALS['version'] = "2.0";
|
|
|
|
//echo "".$GLOBALS['appid']."";
|
|
/**
|
|
$result = $this->getToken($openapiurl,$appid,$secretkey,$loginname,$loginpwd);
|
|
echo "".$result."<br/>";
|
|
$obj=json_decode($result);
|
|
if($obj->ret==0){
|
|
$data=$obj->data;
|
|
echo "session:".$data->session."<br/>";
|
|
echo "secretkey:".$data->secretkey."<br/>";
|
|
$GLOBALS['token_session'] = $data->session;
|
|
$GLOBALS['token_secretkey']= $data->secretkey;
|
|
}else{
|
|
return false;
|
|
}
|
|
*/
|
|
return true;
|
|
}
|
|
|
|
//获取系统调用的权限
|
|
public function getToken($openapiurl,$appid,$secretkey,$loginname,$loginpwd){
|
|
|
|
$aes=new security();
|
|
$method="qdpay.oauth.com.token.get";
|
|
$encryptdata = $aes->encrypt($secretkey,$secretkey,"{\"loginname\":\"".$loginname ."\",\"loginpwd\":\"".$loginpwd."\"}");
|
|
$time=time();
|
|
$signstr = md5($secretkey.$appid.$encryptdata.$GLOBALS['format'].$method.$time.$GLOBALS['version'].$secretkey);
|
|
$getdata = "appid=".$appid."&method=".$method."&format=".$GLOBALS['format']."&data=".$encryptdata."&v=".$GLOBALS['version']."&timestamp=".$time."&sign=".$signstr;
|
|
$url =$openapiurl."?".$getdata;
|
|
//echo $url;
|
|
$httphelper=new HttpHelper();
|
|
$result=$httphelper->getSSLHttp($url);
|
|
return $result;
|
|
}
|
|
|
|
//调用其它方法
|
|
public function methodInvoke($method,$data){
|
|
$aes=new security();
|
|
|
|
$encryptdata = $aes->encrypt($GLOBALS['token_secretkey'],$GLOBALS['token_secretkey'],$data);
|
|
$time=time();
|
|
//$signstr = md5($appid.$method.$format.$encryptdata.$v.$time.$session.$appkey);
|
|
$signstr = md5($GLOBALS['token_secretkey'].$GLOBALS['appid'].$encryptdata.$GLOBALS['format'].$method.$GLOBALS['token_session'].$time.$GLOBALS['version'].$GLOBALS['token_secretkey']);
|
|
$getdata = "method=".$method."&appid=".$GLOBALS['appid']."&format=".$GLOBALS['format']."&data=".$encryptdata."&v=".$GLOBALS['version']."×tamp=".$time."&session=".$GLOBALS['token_session']."&sign=" .$signstr;
|
|
$url = $GLOBALS['open_api_url']."?".$getdata;
|
|
// echo $url;
|
|
$httphelper=new HttpHelper();
|
|
$result=$httphelper->getSSLHttp($url);
|
|
return $result;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|