<?php
class api_getinfo{ 
    public function getdocid($title) {		 
	     $url = "https://api.douhao.com/api/v1/article/make";
		 $array = array(
		 'sercet' => C('ftx_ai_sercet'),
		 'title' => $title,
		 'type'=>'seo'
		 );	
		 $data = json_encode($array);	 
		 $ch = curl_init();      
		 $timeout = 300;       
		 curl_setopt($ch, CURLOPT_URL, $url);     
		 curl_setopt($ch, CURLOPT_REFERER, $_SERVER["HTTP_REFERER"]);    
		 curl_setopt($ch, CURLOPT_POST, true);      
		 curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
		 curl_setopt($ch, CURLOPT_HTTPHEADER,array(
                'Content-Type: application/json; charset=utf-8',
                'Content-Length:' . strlen($data),
                'Cache-Control: no-cache',
                'Pragma: no-cache'
         ));
		 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);		 
		 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
		 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
		 $source = curl_exec($ch);      
		 curl_close($ch);	 
		 $ckapi = json_decode($source,true);		 
        return $ckapi;
    }   
	
	public function getinfofromid($doc_id) {		 
	     $url = "https://api.douhao.com/api/v1/article/get";
		 $array = array(
		 'sercet' => C('ftx_ai_sercet'),
		 'doc_id' => $doc_id,		 
		 );	
		 $data = json_encode($array);	 
		 $ch = curl_init();      
		 $timeout = 300;       
		 curl_setopt($ch, CURLOPT_URL, $url);     
		 curl_setopt($ch, CURLOPT_REFERER, $_SERVER["HTTP_REFERER"]);    
		 curl_setopt($ch, CURLOPT_POST, true);      
		 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);  
		 curl_setopt($ch, CURLOPT_HTTPHEADER,array(
                'Content-Type: application/json; charset=utf-8',
                'Content-Length:' . strlen($data),
                'Cache-Control: no-cache',
                'Pragma: no-cache'
         ));
		 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);		 
		 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
		 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
		 $source = curl_exec($ch);      
		 curl_close($ch);	 
		 $ckapi = json_decode($source,true);		 
        return $ckapi;
    }
  
}
?>