|
|
@@ -37,6 +37,9 @@ class WagentProxy
|
|
|
public function writeTokenCache($array)
|
|
|
{
|
|
|
$ret = file_put_contents($this->cacheFile, json_encode($array, 256));
|
|
|
+ if (!$ret) {
|
|
|
+ throw new \Exception("缓存文件写入失败,请检查文件写入权限", 1005);
|
|
|
+ }
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
@@ -185,6 +188,22 @@ class WagentProxy
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ //抽象公共请求方法[一定得带上method参数]
|
|
|
+ public function commfun(Array $datas, $isPost = 0)
|
|
|
+ {
|
|
|
+ if (!isset($datas['method'])) {
|
|
|
+ throw new \Exception("modthod参数缺失", 1006);
|
|
|
+ }
|
|
|
+ $arrcomm = ['agent' => $this->configs['name'], 'method' => $datas['method']];
|
|
|
+ unset ($datas['method']);
|
|
|
+ $urlData = $this->makeUrl('/InApi-index/dobusiness', array_merge($datas, $arrcomm), $isPost);
|
|
|
+ if ($isPost) {
|
|
|
+ $ret = $this->request_post($urlData['url'], ['params' => $urlData['param'], 'Key' => $urlData['key']], 1);
|
|
|
+ } else {
|
|
|
+ $ret = $this->request_post($urlData);
|
|
|
+ }
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
|
|
|
/////////////////////////////////////以下为具体业务逻辑
|
|
|
//请在调用以下方法前,调用 Init方法作初始化操作
|
|
|
@@ -192,46 +211,74 @@ class WagentProxy
|
|
|
//2.1检测账户是否存在
|
|
|
public function caie($name)
|
|
|
{
|
|
|
- $arrcomm = ['agent' => $this->configs['name'], 'method' => 'caie'];
|
|
|
- $arrthis = ['username' => $name];
|
|
|
-
|
|
|
- $url = $this->makeUrl('/InApi-index/dobusiness', array_merge($arrcomm, $arrthis));
|
|
|
- $ret = $this->request_post($url);
|
|
|
- return $ret;
|
|
|
+ return $this->commfun(['method' => 'caie', 'username' => $name]);
|
|
|
}
|
|
|
|
|
|
//2.2 检测并创建账号
|
|
|
public function caca($name, $pass)
|
|
|
{
|
|
|
- $arrcomm = ['agent' => $this->configs['name'], 'method' => 'caca'];
|
|
|
- $arrthis = ['username' => $name, 'password' => $pass];
|
|
|
-
|
|
|
- $url = $this->makeUrl('/InApi-index/dobusiness', array_merge($arrcomm, $arrthis));
|
|
|
- $ret = $this->request_post($url);
|
|
|
- return $ret;
|
|
|
+ return $this->commfun(['method' => 'caca', 'username' => $name, 'password' => $pass]);
|
|
|
}
|
|
|
|
|
|
///2.3用户查询余额
|
|
|
public function gb($name, $pass)
|
|
|
{
|
|
|
- $arrcomm = ['agent' => $this->configs['name'], 'method' => 'gb'];
|
|
|
- $arrthis = ['username' => $name, 'password' => $pass];
|
|
|
-
|
|
|
- $url = $this->makeUrl('/InApi-index/dobusiness', array_merge($arrcomm, $arrthis));
|
|
|
- $ret = $this->request_post($url);
|
|
|
- return $ret;
|
|
|
+ return $this->commfun(['method' => 'gb', 'username' => $name, 'password' => $pass]);
|
|
|
}
|
|
|
|
|
|
///2.4用户密码更改 (用post方法提交的例子,注意参数格式)
|
|
|
public function ua($name, $pass)
|
|
|
{
|
|
|
- $arrcomm = ['agent' => $this->configs['name'], 'method' => 'ua'];
|
|
|
- $arrthis = ['username' => $name, 'password' => $pass];
|
|
|
+ return $this->commfun(['method' => 'ua', 'username' => $name, 'password' => $pass], 1);
|
|
|
+ }
|
|
|
|
|
|
- $urlarr = $this->makeUrl('/InApi-index/dobusiness', array_merge($arrcomm, $arrthis), 1);
|
|
|
- $ret = $this->request_post($urlarr['url'], ['params' => $urlarr['param'], 'Key' => $urlarr['key']], 1);
|
|
|
- return $ret;
|
|
|
+ ///2.5 代理转给用户或用户转回代理
|
|
|
+ public function ptc($name, $pass, $billno, $credit, $type)
|
|
|
+ {
|
|
|
+ return $this->commfun(['method' => 'ptc', 'username' => $name, 'password' => $pass, 'billno' => $billno, 'credit' => $credit, 'type' => $type], 1);
|
|
|
}
|
|
|
|
|
|
+ ///2.6 代理转给用户或用户转回代理的转账查询
|
|
|
+ public function ctc($name, $pass, $billno, $type)
|
|
|
+ {
|
|
|
+ return $this->commfun(['method' => 'ctc', 'username' => $name, 'password' => $pass, 'billno' => $billno, 'type' => $type]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.7 按订单查询转账信息
|
|
|
+ public function gct($billno)
|
|
|
+ {
|
|
|
+ return $this->commfun(['method' => 'gct', 'billno' => $billno]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.8 用户进入游戏
|
|
|
+ public function tg($name, $pass, $gametype = 2, $domain = '', $gamekind = 0, $iframe = '0', $platformname = '', $lang = 'zh')
|
|
|
+ {
|
|
|
+ return $this->commfun(['method' => 'tg', 'username' => $name, 'password' => $pass, 'gametype' => $gametype, 'domain' => $domain, 'gamekind' => $gamekind, 'iframe' => $iframe, 'platformname' => $platformname, 'lang' => $lang], 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //2.9 用户进入游戏
|
|
|
+ public function gr($name, $pass, $datestart, $dateend)
|
|
|
+ {
|
|
|
+ return $this->commfun(['method' => 'tg', 'username' => $name, 'password' => $pass, 'datestart' => $datestart, 'dateend' => $dateend]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2.10 获取用户的体育投注数据
|
|
|
+ public function gsbrbv($billno, $isjs)
|
|
|
+ {
|
|
|
+ return $this->commfun(['method' => 'gsbrbv', 'vendorid' => $billno, 'isjs' => $isjs]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//...............
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 使用例子
|
|
|
+ * // $config = ['name' => 'agentname', 'key' => 'agentkey', 'secret' => 'agentsecret', 'domain' => 'http://sports.bocai108.com', 'cachefile' => '/tmp/t234asfasf212128233333.cache'];
|
|
|
+ * $config = ['name' => 'agentname', 'key' => 'agentkey', 'secret' => 'agentsecret'];
|
|
|
+ * $proxy = new WagentProxy();
|
|
|
+ * $proxy->Init($config);
|
|
|
+ * $ret1 = $proxy->ua('onmygod', '123456789');
|
|
|
+ *
|
|
|
+ * print_r($ret1);
|
|
|
+ */
|