加入收藏 | 设为首页 | 会员中心 | 我要投稿 南平站长网 (https://www.0599zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php版新浪支付接口之新建接口记录

发布时间:2022-02-23 18:59:16 所属栏目:PHP教程 来源:互联网
导读:在使用新浪支付接口的时候,需要进行一个接口的创建,刚刚由夏日博客新建的一个新浪接口,整合的是方维P2P网贷系统,下面这个接口还是比较简单的,只是一个解绑认证信息的接口,也就是解绑我们在新浪上面的身份证等信息,操作步骤如下,仅供夏日参考学习使
  在使用新浪支付接口的时候,需要进行一个接口的创建,刚刚由夏日博客新建的一个新浪接口,整合的是方维P2P网贷系统,下面这个接口还是比较简单的,只是一个解绑认证信息的接口,也就是解绑我们在新浪上面的身份证等信息,操作步骤如下,仅供夏日参考学习使用。
 
  1,后台复制一个按钮链接
 
  2,/admin/Tpl/default/Common/js/user.js 添加一个跳转,注意名字
 
  3, php添加一个类,路径-->app/lib/module/collocationModule.class.php,代码如下:
 
  public function AdminUnbindUser(){   
      $user_id=(int)$_GET['user_id'] ;   
      $class_name = getCollName();   
         
      require_once APP_ROOT_PATH."system/collocation/".$class_name."_collocation.php";   
      $collocation_class = $class_name."_collocation";   
      $collocation_object = new $collocation_class();   
         
      $collocation_code = $collocation_object->AdminUnbindUser($user_id);   
  }  
  4,在 /system/collocation/Sina_collocation.php 文件中添加如下代码:
 
  function AdminUnbindUser($uid){   
      require_once(APP_ROOT_PATH.'system/collocation/sina/AdminUnbindUser.php');     
      return AdminUnbindUser($uid);   
  }  
  5,到 system/collocation/sina/ 中新建一个 AdminUnbindUser,下面的代码从 /a/zjtg_php_demo/controller/controller_sina.php 中查找服务名称,把类中的文件全复拷贝出来放到 AdminUbindUser($uid) 中,内容如下:
 
  function AdminUnbindUser($uid){   
     $weibopay = new Weibopay();   
     /**************获取解绑认证信息参数****************/   
     $service='unbinding_verify';//服务名称   
     $version=sinapay_version;//接口版本   
     $request_time=date("YmdHis");//请求时间   
     $partner_id=sinapay_partner_id;//合作者身份ID   
     $_input_charset=sinapay_input_charset;//参数编码字符集   
     $sign_type=sinapay_sign_type;//签名类型   
     /****************业务参数***********************/   
     $identity_id=sinapay_identity_id.$uid;//用户标识信息---原来的 $identity_id=$data['identity_id'];//用户标识信息   
     $identity_type=sinapay_identity_type;//用户标识类型   
     $verify_type='MOBILE';//认证类型   
     $param=array();   
     $param['service']=$service;   
     $param['version']=$version;   
     $param['request_time']=$request_time;   
     $param['partner_id']=$partner_id;   
     $param['_input_charset']=$_input_charset;   
     $param['sign_type']=$sign_type;   
     $param['identity_id']=$identity_id;   
     $param['identity_type']=$identity_type;   
     $param['verify_type']=$verify_type;   
     ksort($param);//对签名参数据排序   
     //对请求sina报文进行签名   
     $sign=$weibopay->getSignMsg($param,$sign_type);   
     //将签名结果存入请求sina的数组   
     $param['sign']=$sign;   
     $weibopay->write_log("解绑认证信息请求参数".json_encode($param));   
     $data = $weibopay->createcurl_data($param); // 调用createcurl_data创建模拟表单需要的数据   
     $result = $weibopay->curlPost(sinapay_mgs_url,$data ); // 使用模拟表单提交进行数据提交   
     $result = urldecode ($result);   
     $splitdata = json_decode($result,true);   
     $sign_type = $splitdata ['sign_type'];//签名方式   
     ksort($splitdata); // 对签名参数据排序   
     print_r($param);print_r($splitdata);die();   
     if ($weibopay->checkSignMsg ($splitdata,$sign_type)) {   
         if ($splitdata["response_code"] == 'APPLY_SUCCESS') { // 成功   
             return $splitdata;   
             exit();   
         }else   
         {   
             //业务处理失败   
             return $splitdata;   
             exit();   
         }   
     } else {   
         die ( "sing error!" );   
     }   
        
  }
  其中 /a/zjtg_php_demo/controller/controller_sina.php 中的文件是新浪提供的接口实例,只需传递一个UID即可,其它不用变动。
 
 

(编辑:南平站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读