Browse Source

快乐论文授权改为主动调接口模式

pull/24/head
gavinlau 3 years ago
parent
commit
965e9736af
  1. 2
      config/define.php
  2. 7
      control/api.php
  3. 43
      control/callback.php
  4. 5
      index.php

2
config/define.php

@ -31,8 +31,6 @@
define('API_PDD_UID', 'bf3dfd836648d0d53657');
define('API_PDD_TOKEN', '030d17b10e2dfa7056a0');
define('API_KUAILELUNWEN_UPDATE_PDD_AUTH_INFO', 'http://api.kuailelunwen.com/update_pdd_auth_info');
# order_status 1:待发货,2:已发货待签收,3:已签收 5:全部
define('ORDER_STATUS_WAIT_DELIVER_GOODS', 1);
define('ORDER_STATUS_DELIVERED', 2);

7
control/api.php

@ -84,4 +84,11 @@ class api extends publicBase {
$this->ajax_json(true, 'succ', $res['order_status_get_response']['order_status_list']);
}
public function _api_get_shopinfo() {
$shopinfo = $this->get_shopinfo();
$shopinfo['aid'] = $this->post('aid')+0;
$this->ajax_json(true, 'succ', $shopinfo);
}
}

43
control/callback.php

@ -28,26 +28,29 @@ class callback extends publicBase {
$_SESSION['app_uid'] = $shopinfo['uid'];
$_SESSION['app_name'] = $shopinfo['name'];
$state = $this->get('state');
if(strpos($state, "kuaileaid") !== false) {
$aid = str_replace('kuaileaid_', '', $state)+0;
if ($aid) {
$params = array(
'_uid' => API_PDD_UID,
'_token' => API_PDD_TOKEN,
'aid' => $aid,
'access_token' => $access_token,
'name' => $name,
'expire_time' => $expire_time
);
$json_res = $sobj->postCUrl(API_KUAILELUNWEN_UPDATE_PDD_AUTH_INFO, $params);
$res = json_decode($json_res, true);
if (!$res['status']) $this->show_message($res['info']);
header('Location: http://www.kuailelunwen.com/pay/pay_list/paytype/1');
exit;
}
}
// 因云内不能访问外网 此方案行不通 需要购买出云访问服务才可以
// $state = $this->get('state');
// if(strpos($state, "kuaileaid") !== false) {
// $aid = str_replace('kuaileaid_', '', $state)+0;
// if ($aid) {
// $params = array(
// '_uid' => API_PDD_UID,
// '_token' => API_PDD_TOKEN,
// 'aid' => $aid,
// 'access_token' => $access_token,
// 'name' => $name,
// 'expire_time' => $expire_time
// );
// $json_res = $sobj->postCUrl(API_KUAILELUNWEN_UPDATE_PDD_AUTH_INFO, $params);
// $obj->writeLog('kuailelunwen', 'pdd_auth.log', API_KUAILELUNWEN_UPDATE_PDD_AUTH_INFO.'|'.json_encode($params).'|'.$json_res."\n");
// $res = json_decode($json_res, true);
// if (!$res['status']) $this->show_message($res['info']);
// header('Location: http://www.kuailelunwen.com/pay/pay_list/paytype/1');
// exit;
// }
// }
header('Location: /');
exit;

5
index.php

@ -69,6 +69,7 @@ class run extends publicBase {
if (strtotime($shopinfo['expire_time']) < time()) $this->ajax_json(false, '店铺授权已过期,过期时间'.$shopinfo['expire_time']);
$this->para['_access_token'] = $shopinfo['access_token'];
$this->para['_shopinfo'] = $shopinfo;
$this->control_func = '_api_'.$this->control_func;
}
@ -80,10 +81,8 @@ class run extends publicBase {
$app_name = $_SESSION['app_name'];
if (empty($app_uid) || empty($app_name)) {
$state = $_GET['aid'] ? 'kuaileaid_'.$_GET['aid'] : PDD_AUTH_STATE;
$pobj = new mPdd();
$url = $pobj->getPddAuthUrl($state);
$url = $pobj->getPddAuthUrl();
header('Location:'.$url);
exit;

Loading…
Cancel
Save