php開發(fā)文檔 會員收費1期
介紹
最新項目——會員收費,目的是要以更好的展現(xiàn)形式表現(xiàn)給用戶,以及添加了新功能(會員機制)。
索引
流程圖
1> 展示界面
2> 獲取折扣價格
接口說明
http請求腳本(curl或socket)
測試數(shù)據(jù)
流程圖
其中里面的demo:是通過url進行展現(xiàn),里面的mst是參數(shù),通過不同的參數(shù)進行展現(xiàn)。如:http://www.demo.com/?mst=1表示參數(shù)為1的demo樣式。
展示界面(4種情況)
獲取折扣價格
接口說明
1、開通高級會員
psid=2
pstype=101
2、開通會員
psid=1
pstype=101
3、[會員/高級會員]價格信息
wiki地址:http://wiki.1verge.net/projects:premium:v2:product_rules_api#根據(jù)會員等級id獲取等級信息
4、[是否是會員]
wiki地址:http://wiki.1verge.net/projects:premium:v2:verify_center_api#獲取當前會員等級
5、[折扣信息]
wiki地址:http://wiki.1verge.net/projects:premium:v2:operation_api#根據(jù)用戶id_服務id_服務類型_服務周期數(shù)_獲得當前用戶可以享受的折扣策略
6、可包月節(jié)目+有權(quán)觀看+高級會員則顯示“您是高級會員,可免費觀看此節(jié)目”
7、僅包月節(jié)目+有權(quán)觀看+高級會員提示“續(xù)費”
8、除6以外+有權(quán)觀看則顯示“截止日期”
可以在Premium.class.php中l(wèi)ist_shows_by_pkgid函數(shù)下面繼續(xù)封裝調(diào)用函數(shù)
http請求腳本(curl或socket)
<?php
function httpRequest($url, $hostName, array $params){
$postParams = array();
foreach ($params as $key=>$val) {
$post_params[] = $key.'='.rawurlencode($val);
}
$postString = implode('&', $post_params);
$result = '';
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: ' . $hostName));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'DEMO.COM PREMIUM PHP5 Client ver: ' . phpversion());
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
$result = curl_exec($ch);
curl_close($ch);
} else {
$context = array('http' => array('method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded' . "\r\n".
'Host: '.$hostName . "\r\n".
'User-Agent: TEST.COM BC Test PHP5 Client ver: ' . phpversion() . "\r\n".
'Content-length: ' . strlen($postString),
'content' => $postString));
$contextId = stream_context_create($context);
$handle = fopen($url, 'r', false, $contextId);
if ($handle) {
while (!feof($handle)) $result .= fgets($sock, 4096);
fclose($handle);
}
}
return $result;
}
測試數(shù)據(jù)
1、點播信息節(jié)目ID:1e390718b72311df97c0.html
2、vip用戶ID:123350942
3、普通用戶ID:106738702
有權(quán)觀看的節(jié)目ID:cbfb035e962411de83b1.html
相關(guān)文章
ubuntu10.04配置 nginx+php-fpm模式的詳解
本篇文章是對buntu10.04配置 nginx+php-fpm模式進行了詳細的分析介紹,需要的朋友參考下2013-06-06PHP 閉包獲取外部變量和global關(guān)鍵字聲明變量的區(qū)別講解
閉包是一個常見的概念,我們通常可以將其與回調(diào)函數(shù)配合使用,可以使代碼更加簡潔易讀。這篇文章主要介紹了PHP 閉包獲取外部變量和global關(guān)鍵字聲明變量的區(qū)別,需要的朋友可以參考下2017-12-12TP5(thinkPHP5)框架使用ajax實現(xiàn)與后臺數(shù)據(jù)交互的方法小結(jié)
這篇文章主要介紹了TP5(thinkPHP5)框架使用ajax實現(xiàn)與后臺數(shù)據(jù)交互的方法,結(jié)合實例形式總結(jié)分析了thinkPHP5使用ajax與后臺數(shù)據(jù)交互的兩種實現(xiàn)方法及相關(guān)操作技巧,需要的朋友可以參考下2020-02-02thinkPHP5.1框架中Request類四種調(diào)用方式示例
這篇文章主要介紹了thinkPHP5.1框架中Request類四種調(diào)用方式,結(jié)合實例形式分析了thinkPHP5.1框架中Request類傳統(tǒng)調(diào)用、靜態(tài)調(diào)用、依賴注入及request屬性四種調(diào)用方式,需要的朋友可以參考下2019-08-08