mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix for #713
This commit is contained in:
parent
f5bb3d3f1b
commit
331b117189
@ -733,39 +733,17 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
|
|
||||||
$invitation = $this->invitations[0];
|
$invitation = $this->invitations[0];
|
||||||
$link = $invitation->getLink();
|
$link = $invitation->getLink();
|
||||||
|
$key = env('PHANTOMJS_CLOUD_KEY');
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
|
||||||
if (Utils::isNinjaDev()) {
|
if (Utils::isNinjaDev()) {
|
||||||
$link = env('TEST_LINK');
|
$link = env('TEST_LINK');
|
||||||
}
|
}
|
||||||
|
|
||||||
$jsonEncodedData = json_encode([
|
$url = "http://api.phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$link}?phantomjs=true%22,renderType:%22html%22%7D";
|
||||||
'url' => "{$link}?phantomjs=true",
|
|
||||||
'renderType' => 'html',
|
|
||||||
'outputAsJson' => false,
|
|
||||||
'renderSettings' => [
|
|
||||||
'passThroughHeaders' => true,
|
|
||||||
],
|
|
||||||
// 'delayTime' => 1000,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$opts = [
|
$pdfString = file_get_contents($url);
|
||||||
CURLOPT_URL => PHANTOMJS_CLOUD . env('PHANTOMJS_CLOUD_KEY') . '/',
|
$pdfString = strip_tags($pdfString);
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
|
||||||
CURLOPT_POST => 1,
|
|
||||||
CURLOPT_POSTFIELDS => $jsonEncodedData,
|
|
||||||
CURLOPT_HTTPHEADER => [
|
|
||||||
'Content-Type: application/json',
|
|
||||||
'Content-Length: '.strlen($jsonEncodedData)
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
curl_setopt_array($curl, $opts);
|
|
||||||
$response = curl_exec($curl);
|
|
||||||
curl_close($curl);
|
|
||||||
|
|
||||||
$pdfString = strip_tags($response);
|
|
||||||
|
|
||||||
if ( ! $pdfString || strlen($pdfString) < 200) {
|
if ( ! $pdfString || strlen($pdfString) < 200) {
|
||||||
Utils::logError("PhantomJSCloud - failed to create pdf: {$pdfString}");
|
Utils::logError("PhantomJSCloud - failed to create pdf: {$pdfString}");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user