我正在使用https://phantomjscloud.com生成网站的 pdf 快照。我正在使用一个非常基本的示例,如下所示:
$Foptions = new stdClass();
$Foptions->url = 'http://lr.boatsetter.com/boat/?id=1';
$Foptions->renderType = "pdf";
$optionsjson = json_encode($Foptions);
$url = 'http://PhantomJScloud.com/api/browser/v2/myapi/';
$payload = $optionsjson;
$options = array(
'http' => array(
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => $payload
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
var_dump($result);
file_put_contents('boat_1.pdf',$result);
当 $Foptions->url 是 amazon.com 或 google.com 时,这非常有效。但不是在我的例子中。可能是什么错误?