PC游戏对接文档

一、环境配置

  1. PC端文档说明

    PC端接入游戏,只需要接入对应接口即可

  2. 请求域名:

    https://sdk.gxlyyx.cn    

  3. 配置文件

    游戏的运行目录需要新增配置文件, 文件名必须为:bstconfig.ini
           

    [游戏名称]
    domain=https://sdk.gxlyyx.cn
    alliance=0
    promotion_id=0
    promotion_type=

  4. 调试工具

    下载PC端接口调试工具.zip

二、初始化SDK

  1. 接口说明

    游戏初始化完成后,需要初始化SDK

  2. 请求URL

    /controller/init.ashx?action=get_init_par_win

  3. 请求方式

    HTTP POST  application/x-www-form-urlencoded (POST Form表单形式)        

  4. 请求参数

    参数如下

    字段必填类型示例值描述
    app_idString(16)1650e68cf57045c1我方游戏的app_id
    allianceString(16)0INI配置文件的alliance值
  5. 返回参数(JSON格式)

    返回参数如下

    参数必填类型示例值说明
    statusint10:失败;1:成功
    msgstring初始化成功初始化结果描述
    paymethodsArray["mihua:alipay","mihua:alipay_scan"]支付方式列表
  6. 返回示例数据

    成功返回:        

    {"status":1,"msg":"初始化成功","paymethods":["mihua:alipay","mihua:alipay_scan"]}

           

           

           

    失败返回:        

    {"status":0, "msg":"游戏不存在或app_id错误"}

           

           

       

三、登录游戏

  1. 接口说明

    用户登录并获取小号列表及实名信息

  2. 请求URL

    /controller/login.ashx?action=username_login

  3. 请求方式

    HTTP POST  application/x-www-form-urlencoded (POST Form表单形式)        

  4. 请求参数

    参数如下

    字段必填类型示例值描述
    app_idString(16)1650e68cf57045c1我方游戏的app_id
    timestamplong1710000000时间戳(秒)
    usernamestringtest001用户名
    passwordstring123456密码
    ipstring
    192.168.0.1ip地址
    fidstringABCDEF123456设备序列号
    devicenamestringPC-WIN10设备名称
    platstringwin固定值
  5. 返回参数(JSON格式)

    返回参数如下

    参数必填类型示例值说明
    statusint10:失败;1:成功
    msgstring登录成功请求结果描述
    users_smallArray[]小号列表(users_small对象属性见下方表格)
    isauthenticationint10:未实名认证;1:已实名认证
    ageint20年龄
    show_forcemobileint00:不显示绑定手机;1:显示绑定手机
    show_forcemobile_closeint10:不允许跳过绑定手机;1:允许跳过绑定手机
  6. users_small对象

    字段必填类型示例值描述
    uidstring10001小号uid
    small_titlestring小号1小号显示名称
  7. 返回示例数据

    成功返回:        

    {"status":1,"msg":"登录成功","isauthentication":1,"age":20,"show_forcemobile":0,"show_forcemobile_close":1,"users_small":[{"uid":"10001","small_title":"小号1"}]}

           

           

           

    失败返回:        

    {"status":0,"msg":"用户名或密码错误"}

           

           

       

  8. 注意事项

    注意:登录成功后,
    需要判断返回值isauthentication  是否实名认证了
    如果这个值是0   则显示实名认证框, 让他进行实名认证
    如果是1 则判断age (年龄),如果年龄小于18,则禁止进入游戏
    如果是1且年龄大于18, 则显示小号列表 , 让用户进游戏
           

四、进入游戏

  1. 服务端验签

    进入游戏之前,需要调用服务端登录验证(参考服务端文档,点击顶部"服务端文档进行查看")

  2. 进入游戏

    说明:如果小号列表数量大于1,则显示小号列表(需要研发画一个小号弹框), 点击小号,携带小号uid进入游戏;

    如果数量为1,则可以使用小号的uid直接进入游戏

       2.在进入游戏之前,需要调用服务端登录验证(参考服务端文档,点击顶部"服务端文档进行查看")

五、手机注册

  1. 接口说明

    使用手机号注册账号

  2. 请求URL

    /controller/register.ashx?action=reg_mobile

  3. 请求方式

    HTTP POST  application/x-www-form-urlencoded (POST Form表单形式)        

  4. 请求参数

    参数如下

    参数必填类型示例值描述
    app_idString(16)1650e68cf57045c1我方游戏的app_id
    promotion_idstring0INI配置文件的promotion_id
    promotion_typestring0INI配置文件的promotion_type
    platstringwin固定值
    timestamplong1710000000时间戳(秒)
    ipstring127.0.0.1客户端IP
    mobilestring13800138000手机号码
    codestring123456短信验证码(请先调用发送验证码接口)
    passwordstring123456密码
    fidstringABCDEF123456设备序列号
    devicenamestringPC-WIN10设备名称
  5. 返回参数(JSON格式)

    返回参数如下

    参数必填类型示例值说明
    statusint10:失败;1:成功
    msgstring注册成功请求结果描述
  6. 返回示例数据

    成功返回:        

    {"status":1,"msg":"注册成功"}

           

           

           

    失败返回:        

    {"status":0,"msg":"验证码错误或已过期"}

           

           

       

六、发送验证码

  1. 接口说明

    手机注册发送验证码

  2. 请求URL

    /controller/register.ashx?action=send_sms_code

  3. 请求方式

    HTTP POST  application/x-www-form-urlencoded (POST Form表单形式)        

  4. 请求参数

    参数如下

    参数必填类型示例值描述
    app_idString(16)1650e68cf57045c1我方游戏的app_id
    timestamplong1710000000时间戳(秒)
    ipstring127.0.0.1客户端IP
    mobilestring13800138000手机号码
  5. 返回参数(JSON格式)

    返回参数如下

    参数必填类型示例值说明
    statusint10:失败;1:成功
    msgstring发送成功请求结果描述
  6. 返回示例数据

    成功返回:        

    {"status":1,"msg":"发送成功"}

           

           

           

    失败返回:        

    {"status":0,"msg":"手机号格式错误或发送频繁"}

           

           

       

七、用户名注册

  1. 接口说明

    使用用户名注册账号

  2. 请求URL

    /controller/register.ashx?action=reg_user_name

  3. 请求方式

    HTTP POST  application/x-www-form-urlencoded (POST Form表单形式)        

  4. 请求参数

    参数如下

    参数必填类型示例值描述
    app_idString(16)1650e68cf57045c1我方游戏的app_id
    promotion_idstring0sdk.promotion_id
    promotion_typestring0sdk.promotion_type
    platstringwin固定值
    timestamplong1710000000时间戳(秒)
    ipstring127.0.0.1客户端IP
    usernamestringtest001用户名
    password_new_1string123456新密码
    password_new_2string123456确认新密码
    fidstringABCDEF123456设备序列号
    devicenamestringPC-WIN10设备名称
  5. 返回参数(JSON格式)

    返回参数如下

    参数必填类型示例值说明
    statusint10:失败;1:成功
    msgstring注册成功请求结果描述
  6. 返回示例数据

    成功返回:        

    {"status":1,"msg":"注册成功"}

           

           

           

    失败返回:        

    {"status":0,"msg":"用户名已存在"}

           

           

       

八、实名认证

  1. 接口说明

    提交实名认证信息

  2. 请求URL

    /controller/register.ashx?action=authentication

  3. 请求方式

    HTTP POST  application/x-www-form-urlencoded (POST Form表单形式)        

  4. 请求参数

    参数如下

    参数必填类型示例值描述
    app_idString(16)1650e68cf57045c1我方游戏的app_id
    idcard_realnamestring张三身份证姓名
    idcard_nostring110101199001011234身份证号
    usernamestringtest001用户名
    passwordstring123456密码
  5. 返回参数(JSON格式)

    返回参数如下

    参数必填类型示例值说明
    statusint10:失败;1:成功
    msgstring认证成功请求结果描述
  6. 返回示例数据

    成功返回:        

    {"status":1,"msg":"认证成功"}

           

           

           

    失败返回:        

    {"status":0,"msg":"身份证信息不匹配"}

           

           

       

九、角色上报

  1. 接口说明

    上报游戏角色信息(登录/注册/升级/退出等事件)

  2. 请求URL

    /controller/gamerole.ashx?action=uploadgameroleinfo

  3. 请求方式

    HTTP POST  application/x-www-form-urlencoded (POST Form表单形式)        

  4. 请求参数

    参数如下

    参数必填类型示例值描述
    appid                                        String(16)                    1650e68cf57045c1,注意:请求参数appid中间没有_                    我方游戏的app_id                    
    uidstring10001小号uid
    orleplatstringwin固定值
    gamerolestring{"serverid":"1","servername":"1区","roleid":"10000","rolename":"角色名称",....}角色对象JSON字符串
  5. gamerole对象

    JSON字符串内容)

    字段必填类型示例值描述
    serveridstring1区服ID
    servernamestring1区区服名称
    roleidstring10000角色ID
    rolenamestringH5角色名称角色名称
    rolelevelint58角色等级
    rolebalancestring1000角色游戏内货币余额
    partyidstringdxdy帮派ID
    partynamestringdxdy帮派名称
    rolepowerstring100000角色战力
    viplevelstringVIP8VIP等级
    rolegenderstring角色性别
    partyrolenamestring天下第一帮角色在帮派名称
    professionidstring1角色职业Id
    professionstring法师角色职业名称
    friendlistArray[]角色好友列表
    eventnamestring升级事件类型: 登录/注册/升级/退出
  6. 请求示例数据

    {"app_id":"1650e68cf57045c1","uid":"10001","orleplat":"win","gamerole":"{\"serverid\":\"1\",\"servername\":\"1区\",\"roleid\":\"10000\",\"rolename\":\"H5角色名称\",\"rolelevel\":58,\"rolebalance\":\"1000\",\"partyid\":\"dxdy\",\"partyname\":\"dxdy\",\"rolepower\":\"100000\",\"viplevel\":\"VIP8\",\"rolegender\":\"男\",\"partyrolename\":\"天下第一帮\",\"professionid\":\"1\",\"profession\":\"法师\",\"friendlist\":[],\"eventname\":\"升级\"}"}

           

           

       

  7. 返回参数(JSON格式)

    返回参数如下

    参数必填类型示例值说明
    statusint10:失败;1:成功
    msgstring上报成功请求结果描述
  8. 返回示例数据

    成功返回:        

    {"status":1,"msg":"上报成功"}

           

           

           

    失败返回:        

    {"status":0,"msg":"参数错误"}

           

           

       

十、充值

  1. 接口说明

    创建本地订单并发起支付

  2. 请求URL

    /controller/gameorder.ashx?action=create_local_order

  3. 请求方式

    HTTP POST  application/x-www-form-urlencoded (POST Form表单形式)        

  4. 请求参数

    参数如下

    参数必填类型示例值描述
    paymethodstringmihua:alipay_scan支付方式(取初始化接口paymethods返回值)
    uidstring10001小号uid
    appid                                        String(16)                    1650e68cf57045c1注意:请求参数appid中间没有_                    我方游戏的app_id                    
    platstringwin固定值
    timestamplong1710000000时间戳(秒)
    gamerolestring{\"serverid\":\"1\",\"servername\":\"1区\",\"roleid\":\"10000\"}角色对象JSON字符串(见角色上报)
    orderinfostring{\"cpOrderID\":\"test1710000000\",\"amount\":\"1\",\"count\":\"10\",\"goodsID\":\"1001\",\"goodsName\":\"点券\"}订单对象JSON字符串(对象字段见下方表格)
    coupon_idstring0折扣券ID(预留,传0即可)
    signstring2b4c3d...签名

    orderinfo对象(JSON字符串内容)
           

    字段必填类型示例值描述
    cpOrderIDstringtest1710000000cp的订单编号
    amountstring1订单金额
    countstring10购买的游戏币数量
    goodsIDstring1001游戏方商品Id
    goodsNamestring点券商品名称
    goodsdescstring月卡商品描述
    extrasParamsstring
    透传参数(不参与签名)
  5. 签名说明

    string signstr = "amount={amount}&app_id={app_id}&cporder={cporder}&timestamp={timestamp}&uid={uid}" + "{pay_key}";

           

           

           

    这里使用pay_key进行签名; 金额amount单位为分,需要把元金额乘以100

    说明: app_id对应请求参数appid, cporder对应orderinfo中的cpOrderID

  6. 返回参数(JSON格式)

    返回参数如下

    参数必填类型示例值说明
    statusint10:失败;1:成功
    order_idstring20260312123456订单号
    urlstringhttps://pay.example.com/xxx支付链接
    order_amountstring1.00订单金额
    pay_amountstring1.00应付金额
  7. 返回示例数据

    成功返回:        

    {"status":1,"order_id":"20260312123456","url":"https://pay.example.com/xxx","order_amount":"1.00","pay_amount":"1.00"}

           

           

           

    失败返回:        

    {"status":0,"msg":"签名错误"}