Php PhantomJSAPI错误

Php PhantomJSAPI错误,php,phantomjs,php-phantomjs,Php,Phantomjs,Php Phantomjs,我正在使用生成网站的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/mya

我正在使用生成网站的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时,这一点非常有效。但不是以我为例。可能是什么错误?

我正在使用http api及其工作原理:

$headers  =  array( "Accept:" );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$wp_upload_dir = wp_upload_dir();
$upload_dir = $wp_upload_dir['basedir'] . '/pdf/';
$url  = 'https://phantomjscloud.com/api/browser/v2/myapi/?request={url:%22'.get_home_url().'/boat/?id='.$boat_id.'%22,renderType:%22pdf%22}';
$path = $upload_dir."boat_".$boat_id.".pdf";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, $url);

$data = curl_exec($ch);

curl_close($ch);

$result = file_put_contents($path, $data);
    if(!$result){
        echo "error";
    }else{
        echo "success";
    }

$file = $path;
$filename = 'Boat_'.$boat_id.'.pdf'; 
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

@readfile($file);