REST API provides programmatic access to GoLogin App. Create a new browser profile, get a list of all browser profiles, add a browser profile and running
GoLogin supports Linux, MacOS and Windows platforms.
clone or download this repository
https://github.com/olegopro/phpgologin.git
for running gologin-selenium.php install selenium
composer require php-webdriver/webdriver
for Selenium need download webdriver
Where is token? API token is here. To have an access to the page below you need register GoLogin account.
namespace App;
use Dotenv\Dotenv;
use Facebook\WebDriver\Chrome\ChromeDriver;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
require './vendor/autoload.php';
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$gl = new GoLogin([
'token' => $_ENV['TOKEN'],
'profile_id' => 'yU0Pr0f1leiD',
'port' => GoLogin::getRandomPort()
//'tmpdir' => __DIR__ . '/temp',
]);
if (strtolower(PHP_OS) == 'linux') {
putenv("WEBDRIVER_CHROME_DRIVER=./chromedriver");
} elseif (strtolower(PHP_OS) == 'darwin') {
putenv("WEBDRIVER_CHROME_DRIVER=./mac/chromedriver");
} elseif (strtolower(PHP_OS) == 'winnt') {
putenv("WEBDRIVER_CHROME_DRIVER=chromedriver.exe");
}
$debugger_address = $gl->start();
var_dump($debugger_address) . PHP_EOL;
$chromeOptions = new ChromeOptions();
$chromeOptions->setExperimentalOption('debuggerAddress', $debugger_address);
$capabilities = DesiredCapabilities::chrome();
$capabilities->setCapability(ChromeOptions::CAPABILITY_W3C, $chromeOptions);
$driver = ChromeDriver::start($capabilities);
$driver->get('https://php.net');
sleep(20);
$driver->close();
$gl->stop();
php gologin-selenium.php
options
<[Object]> Options for profile
token
<[string]> your API tokenprofile_id
<[string]> profile IDexecutablePath
<[string]> path to executable Orbita file. Orbita will be downloaded automatically if not specified.remote_debugging_port
<[int]> port for remote debuggingtmpdir
<[string]> path to temporary directore for saving profilesextra_params
arrayof <[string]> extra params for browser orbita (ex. extentions etc.)port
<[integer]> Orbita start port$gl = new GoLogin([
'token' => $_ENV['TOKEN'],
'profile_id' => 'yU0Pr0f1leiD',
]);
php gologin-create-profile.php
use App\GoLogin;
use Dotenv\Dotenv;
require './vendor/autoload.php';
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$gl = new GoLogin([
'token' => $_ENV['TOKEN']
]);
//CREATE
$profile_id = $gl->create([
'name' => 'profile_mac',
'os' => 'mac',
'navigator' => [
'language' => 'en-US',
'userAgent' => 'random',
'resolution' => 'random',
'platform' => 'mac'
],
'proxyEnabled' => true,
'proxy' => [
'mode' => 'gologin',
'autoProxyRegion' => 'us'
//'host' => '',
//'port' => '',
//'username' => '',
//'password' => '',
],
'webRTC' => [
'mode' => 'alerted',
'enabled' => true
]
]
);
echo 'profile id=' . $profile_id . PHP_EOL;
$profile = $gl->getProfile($profile_id);
echo 'new profile name=' . $profile->name . PHP_EOL;
//UPDATE
/*$gl->update([
'id' => 'yU0Pr0f1leiD',
'name' => 'profile_mac2'
]);*/
//DELETE
/*$gl->delete('yU0Pr0f1leiD');*/
start browser with profile id
stop browser with profile id
Swagger: link here
Postman: link here
https://pecl.php.net/package/APCu and Zend Thread Safety (ZTS) In php.ini change memory_limit = 512M