function api_err_from_exception($e)
{
    list($code_string, $httpStatusCode) = pa_get_error_name($e->code);
    $ret = api_err($code_string, $e->message);
    if (isset($httpStatusCode)) {
        // set http header error code
        header(HttpStatusCodes::httpHeaderFor($httpStatusCode));
    }
    return $ret;
}
Example #2
0
File: api.php Project: muqidi/PHP
/**
 *  权限校验函数
 */
function check_auth()
{
    $license = get_shop_license();
    // 取出网店 license信息
    if (empty($license['certificate_id']) || empty($license['token']) || empty($license['certi'])) {
        api_err('0x006', 'no certificate');
        //没有证书数据,输出系统级错误:用户权限不够
    }
    if (!check_shopex_ac($_POST, $license['token'])) {
        api_err('0x009');
        //输出系统级错误:签名无效
    }
    /* 对应用申请的session进行验证 */
    $certi['certificate_id'] = $license['certificate_id'];
    // 网店证书ID
    $certi['app_id'] = 'ecshop_b2c';
    // 说明客户端来源
    $certi['app_instance_id'] = 'webcollect';
    // 应用服务ID
    $certi['version'] = VERSION . '#' . RELEASE;
    // 网店软件版本号
    $certi['format'] = 'json';
    // 官方返回数据格式
    $certi['certi_app'] = 'sess.valid_session';
    // 证书方法
    $certi['certi_session'] = $_POST['app_session'];
    //应用服务器申请的session值
    $certi['certi_ac'] = make_shopex_ac($certi, $license['token']);
    // 网店验证字符串
    $request_arr = exchange_shop_license($certi, $license);
    if ($request_arr['res'] != 'succ') {
        api_err('0x001', 'session is invalid');
        //输出系统级错误:身份验证失败
    }
}
Example #3
0
function api_err_from_exception($e)
{
    $code_string = pa_get_error_name($e->code);
    $ret = api_err($code_string, $e->message);
    return $ret;
}