mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Polish for Phantom JS implementation
This commit is contained in:
parent
d7dbde3789
commit
8b9c83da1e
@ -55,24 +55,13 @@ class Phantom
|
||||
|
||||
$file_path = $path . $entity_obj->number . '.pdf';
|
||||
|
||||
$url = rtrim(config('ninja.app_url'), "/") . 'phantom/' . $entity . '/' . $invitation . '?phantomjs_secret='. config('ninja.phantomjs_secret');
|
||||
$url = config('ninja.app_url') . 'phantom/' . $entity . '/' . $invitation->key . '?phantomjs_secret='. config('ninja.phantomjs_secret');
|
||||
|
||||
$json_payload = new \stdClass;
|
||||
$json_payload->url = $url;
|
||||
$json_payload->renderType = "pdf";
|
||||
$key = config('ninja.phantomjs_key');
|
||||
$secret = config('ninja.phantomjs_key');
|
||||
|
||||
$url = "http://PhantomJScloud.com/api/browser/v2/" . config('ninja.phantomjs_key');
|
||||
$payload = json_encode($json_payload);
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/json\r\n",
|
||||
'method' => 'POST',
|
||||
'content' => $payload
|
||||
)
|
||||
);
|
||||
$context = stream_context_create($options);
|
||||
$pdf = file_get_contents($url, false, $context);
|
||||
if ($pdf === FALSE) { /* Handle error */ info("i did not make the PDF from phantom"); }
|
||||
$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$url}%22,renderType:%22pdf%22%7D";
|
||||
$pdf = \App\Utils\CurlUtils::get($phantom_url);
|
||||
|
||||
Storage::makeDirectory($path, 0755);
|
||||
|
||||
@ -80,7 +69,6 @@ class Phantom
|
||||
|
||||
return $file_path;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function displayInvitation(string $entity, string $invitation_key)
|
||||
|
Loading…
Reference in New Issue
Block a user