2023-01-29 10:26:52 +08:00

71 lines
2.2 KiB
PHP

<?php
// 获取第三方书籍
class Getbooks{
public $ssid = '30'; //渠道标识
public $client_id = '1022'; //唯一标识
private $Secretkey = 'EzGKvIlgNTxL2&0e$MVXabY1Ac7BPCFh'; //私钥 key
// 获取所有授权作品
public function GetAll(){
$sign = md5($this->client_id.$this->Secretkey);
$url = 'http://www.ytread.com/apis/share/get_book_list.php?ssid='.$this->ssid.'&sign='.$sign;
$data = $this->curl_gets($url);
$data = json_decode($data,true);
if($data['code']==0){
return false;
}else{
return $data['data'];
}
}
// 获取书籍属性
public function GetBookAttr($aid){
$sign = md5($this->client_id.$this->Secretkey.$aid);
$url = 'http://www.ytread.com/apis/share/get_book_info.php?ssid='.$this->ssid.'&sign='.$sign.'&aid='.$aid;
$data = $this->curl_gets($url);
$data = json_decode($data,true);
if($data['code']==0){
return false;
}else{
return $data['data'];
}
}
// 获取书籍章节列表
public function GetChapterList($aid){
$sign = md5($this->client_id.$this->Secretkey.$aid);
$url = 'http://www.ytread.com/apis/share/get_chapter_list.php?ssid='.$this->ssid.'&sign='.$sign.'&aid='.$aid;
$data = $this->curl_gets($url);
$data = json_decode($data,true);
if($data['code']==0){
return false;
}else{
return $data['data'];
}
}
// 获取章节内容
public function GetChapterContent($aid,$cid){
$sign = md5($this->client_id.$this->Secretkey.$aid.$cid);
$url = 'http://www.ytread.com/apis/share/get_chapter_content.php?ssid='.$this->ssid.'&sign='.$sign.'&aid='.$aid.'&cid='.$cid;
$data = $this->curl_gets($url);
$data = json_decode($data,true);
if($data['code']==0){
return false;
}else{
return $data['data'];
}
}
public function curl_gets($url=''){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec($ch);
return $output;
}
}