在使用新浪支付接口的時候,需要進行一個接口的創建,剛剛由夏日博客新建的一個新浪接口,整合的是方維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即可,其它不用變動。
新聞熱點
疑難解答