2017 © Pedro Peláez
 

library random-user-agent

Generate real random user-agents.

image

campo/random-user-agent

Generate real random user-agents.

  • Wednesday, June 13, 2018
  • by campo
  • Repository
  • 4 Watchers
  • 64 Stars
  • 77,930 Installations
  • PHP
  • 9 Dependents
  • 0 Suggesters
  • 13 Forks
  • 0 Open issues
  • 6 Versions
  • 22 % Grown

The README.md

random-user-agent

Latest Version on Packagist ![Software License][ico-license], (*1)

Generate real random user-agents. The user agent list is largely pulled from the Firefox extension random-agent-spoofer h/t dillbyrne/random-agent-spoofer. Additional entries were sourced from UserAgentString.com and WiiBrew to provide more options for consoles and common web crawlers, (*2)

You should be running at least PHP 5.4 to use this class, (*3)

Install

Via Composer, (*4)

``` bash $ composer require campo/random-user-agent, (*5)


## Usage ### Generating a User Agent To generate a random user agent, you can simply use the following: ``` php echo \Campo\UserAgent::random(), "\n";

Filtering the Type of User Agent

To limit the types of user agents that are returned, you can pass a filter array to random():, (*6)

``` php echo \Campo\UserAgent::random([ 'os_type' => 'Windows', 'device_type' => 'Mobile' ]), "\n";, (*7)


A filter is simply an array with key-value pairs specifying the types of agent strings that you want to have returned. The types of keys in this filtered array may include the following: - `agent_name` - `agent_type` - `device_type` - `os_name` - `os_type` Filters also support passing additional arrays to better segment the results you will receive from random(): ```php echo \Campo\UserAgent::random([ 'os_type' => ['Android', 'iOS'], 'device_type' => ['Mobile', 'Tablet'] ]), "\n";

The above will return only user-agent’s for Android & iOS OS types that are either mobile or tablets., (*8)

To get a list of values that can be accepted by these filter fields, you can use the following methods which will return arrays of values that can be used with the respected fields noted above:, (*9)

  • UserAgent::getDeviceTypes()
  • UserAgent::getAgentTypes()
  • UserAgent::getAgentNames()
  • UserAgent::getOSTypes()
  • UserAgent::getOSNames()

Values passed to filters are case-insensitive, (*10)

Error Handling

This class will throw an exception if either a filter returns no user agent strings, which means that a filter was invalid or too specific, or if one of the fields above was not present, which means that this library has been corrupted., (*11)

License

The MIT License (MIT). Please see License File for more information., (*12)

The Versions

13/06 2018

dev-master

9999999-dev

Generate real random user-agents.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Joe Campo

user agent user-agent user agents spoofing user

13/06 2018

1.3.0

1.3.0.0

Generate real random user-agents.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Joe Campo

user agent user-agent user agents spoofing user

12/11 2016

1.2.0

1.2.0.0

Generate real random user-agents.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Joe Campo

user agent user-agent user agents spoofing user

31/01 2016

1.1.0

1.1.0.0

Generate real random user-agents.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Joe Campo

user agent user-agent user agents spoofing user

06/10 2015

1.0.1

1.0.1.0

Generate real random user-agents.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Joe Campo

user agent user-agent user agents spoofing user

05/10 2015

1.0.0

1.0.0.0

Generate real random user-agents.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Joe Campo

user agent user-agent user agents spoofing user