Open tomhapbia opened 6 years ago
I got the same issue .hope someone to help .
$client = Client::getInstance();
$client->getEngine()->setPath('D:\\Program Files (x86)\\phantomjs-2.1.1-windows\bin\\phantomjs.exe');
$client->getEngine()->debug(true);
$width = 800;
$height = 600;
$top = 0;
$left = 0;
/**
* @see JonnyW\PhantomJs\Http\CaptureRequest
**/
$request = $client->getMessageFactory()->createCaptureRequest('https://www.51kid.com/', 'GET');
$request->setOutputFile('D:/phpStudy/WWW/little-feature/storage/app/public/file.jpg');
$request->setViewportSize($width, $height);
$request->setCaptureDimensions($width, $height, $top, $left);
/**
* @see JonnyW\PhantomJs\Http\Response
**/
$response = $client->getMessageFactory()->createResponse();
// Send the request
dd($client->send($request, $response), $request, $response);
@tomhapbia hey,I have sovled this problem . we need to specilize the file path and phantomjs bin path .
$client = Client::getInstance();
$client->getEngine()->setPath('/www/video/bin/phantomjs');
$client->getEngine()->debug(true);
$width = 800;
$height = 600;
$top = 0;
$left = 0;
/**
* @see JonnyW\PhantomJs\Http\CaptureRequest
**/
$name = uniqid();
$storage_path = storage_path('public/capture/' . $name . 'jpg');
$request = $client->getMessageFactory()->createCaptureRequest('https://www.51kid.com/', 'GET');
$request->setOutputFile($storage_path);
$request->setViewportSize($width, $height);
$request->setCaptureDimensions($width, $height, $top, $left);
/**
* @see JonnyW\PhantomJs\Http\Response
**/
$response = $client->getMessageFactory()->createResponse();
// Send the request
dd($client->send($request, $response), $request, $response);
The empty object referenced by @tomhapbia is because PhantomJS is failing to run.
Likely because of this: https://github.com/ariya/phantomjs/issues/10904
Try sudo apt-get install libfontconfig
I am using this code and my response has it's structure but all the key values are null. Any clue on what would cause this? I run on Mac OS, i have done
upx -d /path/to/phantomjs
but still do not work.`<?php require '/vendor/autoload.php';
use JonnyW\PhantomJs\Client;
?>`
and my response look like:
object(JonnyW\PhantomJs\Http\Response)#159 (9) { ["headers"]=> array(0) { } ["status"]=> NULL ["content"]=> NULL ["contentType"]=> NULL ["url"]=> NULL ["redirectURL"]=> NULL ["time"]=> NULL ["console"]=> NULL ["cookies"]=> NULL }