在使用新浪支付介面的時候,需要進行一個介面的建立,剛剛由夏日部落格建立的一個新浪介面,整合的是方維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) 中,內容如下:
<?php
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即可,其它不用變動。