https://github.com/flaviu-chelaru/phantomjs-cloud
PhantomJS API Library - Register on https://phantomjscloud.com/ for an API key. This is NOT an official release. This is usefull to save a screenshot of a webpage or export a webpage as a PDF file
https://github.com/flaviu-chelaru/phantomjs-cloud
api phantom phantom-js phantomjs php-sdk
Last synced: 3 months ago
JSON representation
PhantomJS API Library - Register on https://phantomjscloud.com/ for an API key. This is NOT an official release. This is usefull to save a screenshot of a webpage or export a webpage as a PDF file
- Host: GitHub
- URL: https://github.com/flaviu-chelaru/phantomjs-cloud
- Owner: flaviu-chelaru
- License: mit
- Created: 2017-04-28T15:10:16.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-14T09:49:11.000Z (about 8 years ago)
- Last Synced: 2025-08-24T22:27:21.878Z (7 months ago)
- Topics: api, phantom, phantom-js, phantomjs, php-sdk
- Language: PHP
- Homepage: https://phantomjscloud.com/
- Size: 26.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PhantomJS Cloud
A library to interact with the Phantom JS Cloud
Examples and extensive documentation on the API
https://phantomjscloud.com/docs/http-api/
### Simple example
Write the web page to a JPG file:
```php
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
### Guzzle Example
```php
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();
```
### TODO - What we plan next for this code
* have a directory structure that will allow you to separate PhantomJS classes from helper classes
* migrate public arguments to protected arguments where possible and use setters and getters.
* see TODO's in the class comments
* add examples in the documentation