1.0.0
1.0.0.0PhantomJS Cloud API based on Guzzle
The Requires
by Flaviu Chelaru
PhantomJS Cloud API wrapper
A library to interact with the Phantom JS Cloud, (*1)
Examples and extensive documentation on the API https://phantomjscloud.com/docs/http-api/, (*2)
Write the web page to a JPG file:, (*3)
include_once 'vendor/autoload.php'; $request = new \PhantomJS\PageRequest('http://www.example.com'); file_put_contents('example.com.jpg', $request->getResponse());
This example shouldn't be used in production. If you need to perform advanced HTTP requests to the api, please address a dedicated library for that. This library should be used only to write your requests, (*4)
include_once __DIR__ . '/vendor/autoload.php'; /** * write your phantom js request * @see https://phantomjscloud.com/docs/ */ $request = new \PhantomJS\PageRequest('http://www.example.com'); /** * Initialize Guzzle to perform HTTP requests * @see http://docs.guzzlephp.org/en/stable * The request url will be https://phantomjscloud.com/api/browser/v2/a-demo-key-with-low-quota-per-ip-address/?request={url:%22http://www.example.com%22} */ $client = new GuzzleHttp\Client(); $response = $client->get($request->getApiUrl() . '?request=' . $request->toJSON()); print $response->getBody();
PhantomJS Cloud API based on Guzzle