https://github.com/preferred-pictures/php
A PHP client for the PreferredPictures API.
https://github.com/preferred-pictures/php
ab-testing optimization php-client php-library thompson-sampling
Last synced: 27 days ago
JSON representation
A PHP client for the PreferredPictures API.
- Host: GitHub
- URL: https://github.com/preferred-pictures/php
- Owner: preferred-pictures
- License: mit
- Created: 2020-07-16T14:33:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-10T16:09:39.000Z (over 5 years ago)
- Last Synced: 2025-08-16T09:35:12.304Z (8 months ago)
- Topics: ab-testing, optimization, php-client, php-library, thompson-sampling
- Language: PHP
- Homepage:
- Size: 597 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# PreferredPictures PHP Client Library
The [PreferredPictures](https://preferred.pictures) PHP library provides a convenient way to call the
[PreferredPictures](https://preferred.pictures) API for applications written in PHP.
[View the PHP documentation of this module](https://preferred-pictures.github.io/php/api/classes/PreferredPictures-Client.html)
[View the documentation of the PreferredPicture's API](https://docs.preferred.pictures/api-sdks/api)
[Learn more about what PreferredPictures can do.](https://docs.preferred.pictures/)
## Installation
```
composer require preferred-pictures/client
```
To use the bindings, use Composer's autoload:
```php
require_once('vendor/autoload.php')
```
## Usage
The package needs to be configured with your account's identity and
secret key, which is available in the PreferredPictures interface.
```php
$client = new PreferredPictures\Client("testidentity", "secret123456");
# Create a basic URL to pick between three different images.
$url = $client->createChooseUrl(
["https://www.example.com/image-red.jpg",
"https://www.example.com/image-green.jpg",
"https://www.example.com/image-blue.jpg"],
"test-tournament",
);
# Use a prefix and suffix to make specifying the options less verbose
$url = $client->createChooseUrl(
["red", "green", "blue"],
"test-tournament",
300,
6000,
"https://www.example.com/image-",
".jpg"
);
# The url returned will appear to be something like:
#
# https://api.preferred-pictures.com/choose-url?choices=red%2Cgreen%2Cblue&tournament=testing&expiration=[EXPIRATION]&uid=[UNIQUEID]&ttl=600&prefix=https%3A%2F%2Fexample.com%2Fjacket-&suffix=.jpg&identity=test-identity&signature=[SIGNATURE]
#
# which should be placed where it is needed in your application or templates.
```