Introduction
The latest project - membership fee, aims to present it to users in a better presentation form, and adds new features (membership mechanism).
Index
Flow chart
1> Display interface
2> Get discounted price
Interface description
http request script (curl or socket)
Test data
Flowchart
The demo: is displayed through the url, and the mst inside is the parameter. Through different Parameters are displayed. For example: http://www.demo.com/?mst=1 indicates the demo style with parameter 1.
Display interface (4 situations)
![](http://www.bkjia.com/uploads/allimg/131016/1604015116-0.png)
Get discount price
![](http://www.bkjia.com/uploads/allimg/131016/16040163Q-1.png)
Interface description
1. Activate premium membership
psid=2
pstype=101
2. Activate membership
psid=1
pstype=101
3. [Member/Premium Member] price information
Wiki address: http://wiki.1verge.net/projects:premium:v2:product_rules_api#Get level information based on member level id
4. [Whether you are a member]
Wiki address: http://wiki. 1verge.net/projects:premium:v2:verify_center_api#Get the current membership level
5. [Discount information]
wiki address: http://wiki.1verge.net/projects:premium:v2:operation_api#According to User id_service id_service type_number of service cycles_obtain the discount strategy that current users can enjoy
6. Monthly subscription programs + the right to watch + premium members will display "You are a senior member and can watch this program for free"
7. Only monthly subscription programs + the right to watch + premium members will be prompted to "renew"
8. Except for 6 + the right to watch, the "expiration date" will be displayed
Can be found in Premium.class.php In the list_shows_by_pkgid function, continue to encapsulate the calling function
http request script (curl or socket)
Copy code The code is as follows :
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' . "rn".
'Host: '.$hostName . "rn".
' User-Agent: TEST.COM BC Test PHP5 Client ver: ' . phpversion() . "rn".
'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;
}
Test data
1. On-demand information program ID: 1e390718b72311df97c0.html
2. VIP user ID: 123350942
3. Ordinary users ID: 106738702
Program ID you are entitled to watch: cbfb035e962411de83b1.html
http://www.bkjia.com/PHPjc/325739.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325739.htmlTechArticleIntroducing the latest project-membership charging, the purpose is to present it to users in a better presentation form, and to add New features (membership mechanism). Index Flow chart 1 Display interface 2 Obtain discount...