繁体   English   中英

TCPDF我无法从其他页面(如index.php)获取html?something = something

[英]TCPDF I can't get the html from another page like index.php?something=something

我正在努力从动态生成的页面中使用tcpdf创建pdf文件。

我的问题是我有一个日志记录会话,并且在访问文件时,如果您未登录,则仅获取凭据。

所以我收集html的地方是:

$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'http://www.domain.com/subdir/index.php?something=ref');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
$html = curl_exec($curl_handle);
curl_close($curl_handle);

所以运行它后,我得到的是“ HTTP错误401:-未经授权”。

希望我的解释有意义。

任何帮助都感激不尽!

在使用TCPDF处理PDF时,我遇到了相同的问题,其中卷曲CURLOPT_USERAGENT是TCPDF,如下所示。

curl_setopt($curl_handle, CURLOPT_USERAGENT, 'TCPDF');

我只是评论了这一行,并尝试生成pdf,它起作用了。

我知道这不是正确的方法,但对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM