มันสร้างไฟล์ PDF ให้แต่เปิดไม่ได้ แต่พอลอง print_r ตัว output แล้วขึ้นแจ้งแบบนี้ แสดงว่าตัว API นี้มีปัญหาหรือเปล่าค่ะ
โค้ด: เลือกทั้งหมด
Your usage amount no left
โค้ด: เลือกทั้งหมด
$user_pdf = $key = $this->config['data_pdf_user'];
$pass_pdf = $key = $this->config['data_pdf_pass'];
$api_endpoint = $this->config['data_pdf_server']; //echo ออกมาเป็น http://128.199.200.254:4999/view/1/21/29.7/
$ch = curl_init();
$url = generate_board_url() . '/images/invoice/receipt.html';
curl_setopt($ch, CURLOPT_URL, $api_endpoint . $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $user_pdf . ":" . $pass_pdf);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
//Save file
$output = curl_exec($ch);
print_r($output);exit(); //ดูผล output ออกมา
$path_img = '../images/member_invoice/';
$file_html = $path_img . 'receipt.pdf';
@unlink($file_html);
if (!file_exists($path_img)) {
mkdir($path_img);
chmod($path_img, 0777);
}
file_put_contents($file_html, $output);