dev-master
9999999-dev https://github.com/ksenzee/browserstack-screenshots-phpA PHP client for the Browserstack Screenshots API
MIT GPL-2.0+
The Requires
- php >=5.3.3
- guzzle/guzzle ~3.9
browserstack screenshots
A PHP client for the Browserstack Screenshots API
Get Composer: Download the composer.phar
executable or use the installer., (*1)
sh
$ curl -sS https://getcomposer.org/installer | php
, (*2)
If you already have Composer installed globally, skip this step., (*3)
Create a composer.json file specifying BrowserstackScreenshots as a dependency. You can have Composer do this for you by using this command:, (*4)
``` sh $ php composer.phar require ksenzee/browserstack-screenshots-php:*, (*5)
Or, if you already have Composer installed: ``` sh $ composer require ksenzee/browserstack-screenshots-php:*
Or if you'd rather, you can create your composer.json file by hand:, (*6)
json
{
"require": {
"ksenzee/browserstack-screenshots-php": "*"
}
}
, (*7)
Use Composer to install BrowserstackScreenshots (and anything else you listed in your composer.json file):, (*8)
``` sh $ php composer.phar install, (*9)
Or, if you have Composer installed globally: ``` sh $ composer install
``` php, (*10)
require_once 'vendor/autoload.php';, (*11)
$credentials = array( 'username' => 'janedoe', 'password' => 'abc123', ); $client = new \BrowserstackScreenshots\ScreenshotsClient($credentials);, (*12)
## Requesting a set of screenshots ``` php // The JobConfig class is designed to help you generate JSON that meets the // criteria at http://www.browserstack.com/screenshots/api#generate-screenshots. $config = new \BrowserstackScreenshots\JobConfig(); $config->setUrl('http://www.google.com'); $config->setWaitTime(5); $config->setQuality('original'); $config->addBrowser(array('os' => 'Windows', 'os_version' => '7', 'browser' => 'ie', 'browser_version' => '11.0')); $config->addBrowser(array('os' => 'ios', 'os_version' => '6.0', 'device' => 'iPhone 4S (6.0)')); // You can use it to generate the JSON to describe your job: $json = $config->getJson(); // ... or you can skip the JobConfig class entirely and write your own JSON: $json = '{"url":"https:\/\/www.google.com","wait_time":5,"quality":"original","browsers":[{"os":"Windows","os_version":"7","browser":"ie","browser_version":"11.0"},{"os":"ios","os_version":"6.0","device":"iPhone 4S (6.0)"}]}'; // Once you have valid JSON describing a URL and a set of browsers, use it to // send a POST request to start a screenshot job: print "Requesting screenshots:\n"; $request_info = $client->generateScreenshots($json); $job_id = $request_info['job_id'];
``` php // See whether the job is finished: $finished = $client->jobFinished($job_id);, (*13)
// Get more details on the job status (whether it's done, queued, or timed out): $job_status = $client->getStatus($job_id);, (*14)
// Or just retrieve all available information about your job: $job_info = $client->getJobInfo($job_id);, (*15)
```, (*16)
A PHP client for the Browserstack Screenshots API
MIT GPL-2.0+
browserstack screenshots