Tools to Capture and Convert the Web
GrabzIt's Online Community

Upgrading to v3.4.5 - errors

Ask questions on how to capture or convert web pages or HTML into images, CSV, PDF or DOCX documents as well on how to convert videos into animated GIF's using our API.

Two issues:

(1) When installing via Composer the folder structure is very different and is missing many subfolders such as "ajax", "css", etc. Are these not needed when using Grabzit only from the server side (php)?

(2) After downloading the php client I notice the classes are named differently (previously I had "require_once 'vendor/GrabzIt/lib/GrabzItClient.class.php';" but now it's "require_once 'vendor/GrabzIt/lib/GrabzItClient.php';"). However, when I try to generate a PDF using this code:

// Create the GrabzItClient class
$grabzIt = new GrabzItClient(GRABZIT_APP_KEY, GRABZIT_APP_SECRET);
$pdfOptions = new GrabzItPDFOptions();

I get an error message:

[17-Jan-2021 11:12:26 America/Toronto] PHP Fatal error: Cannot declare class GrabzIt\GrabzItClient, because the name is already in use in /Users/Ross/Dropbox/htdocs/wonderfest_mamp_pro/private/contest/include/vendor/GrabzIt/lib/GrabzItClient.php on line 11

I really want to use v3.4.5 but this is blocking my development.

Asked by Ross Waddell on the 17th of January 2021

It sounds like you are using the legacy version of the PHP  library we moved to using namespaces etc about two and a half years ago. The 3.4.5 legacy version is available on the download page for a manual download.

The legacy version will not be made available on composer as it is only being kept for backwards compatibility. The ajax and css folders are not included as they are part of the demo application and not the library.

If you want to move to the latest version the examples in the PHP documentation should help the changes are relatively minor.

 

 

 

 

Answered by GrabzIt Support on the 17th of January 2021

I installed via Composer but when I go to generate my PDF I get a new error:

 

// Create the GrabzItClient class
$grabzIt = new \GrabzIt\GrabzItClient(GRABZIT_APP_KEY, GRABZIT_APP_SECRET);
$pdfOptions = new \GrabzIt\GrabzItBaseOptions();

$pdfOptions->setPageSize("Letter");
$pdfOptions->setOrientation("Landscape");
$pdfOptions->setMarginLeft(PDF_MARGIN_LEFT);
$pdfOptions->setMarginTop(PDF_MARGIN_TOP);
$pdfOptions->setMarginRight(PDF_MARGIN_RIGHT);

Error:

[17-Jan-2021 13:10:49 America/Toronto] PHP Fatal error: Uncaught Error: Call to undefined method GrabzIt\GrabzItBaseOptions::setPageSize() in /Users/Ross/Dropbox/htdocs/wonderfest_mamp_pro/private/contest/include/createPDF.php:120

 

Answered by Ross Waddell on the 17th of January 2021

You have initialized a GrabzItBaseOptions instead of GrabzItPDFOptions

Answered by GrabzIt Support on the 17th of January 2021