PHPackages                             trustedsearch/php-trustedsearch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. trustedsearch/php-trustedsearch

ActiveLibrary[API Development](/categories/api)

trustedsearch/php-trustedsearch
===============================

TRUSTEDSearch PHP Library

v1.0.5(11y ago)010.9kMITPHPPHP &gt;=5.2

Since Dec 4Pushed 11y ago5 watchersCompare

[ Source](https://github.com/trustedsearch/php-trustedsearch)[ Packagist](https://packagist.org/packages/trustedsearch/php-trustedsearch)[ Docs](http://trustedsearch.org/)[ RSS](/packages/trustedsearch-php-trustedsearch/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (8)Used By (0)

php-trustedsearch
=================

[](#php-trustedsearch)

Obtain the latest version of the TRUSTEDSearch PHP bindings with:

```
git clone https://github.com/trustedsearch/php-trustedsearch

```

Documentation
-------------

[](#documentation)

Please see [http://developers.trustedsearch.org/](http://developers.trustedsearch.org) for up-to-date documentation.

Packagist:

Installation
------------

[](#installation)

### Traditional

[](#traditional)

To get started, add the following to your PHP script:

```
require_once("/path/to/php-trustedsearch/lib/TrustedSearch.php");

```

### Composer

[](#composer)

Add the line below to your "require" block in your composer file

```
trustedsearch/php-trustedsearch

```

Then update your composer

```
composer update

```

Usage
-----

[](#usage)

To start using the package, you need to be given your sandbox and production public &amp; private keys.

### Basic Configuration

[](#basic-configuration)

```
	require_once("/path/to/php-trustedsearch/lib/TrustedSearch.php");

	$publicKey = "XXXX";
	$privateKey = "YYYYY";
	TrustedSearch::setApiPublicKey($publicKey);
	TrustedSearch::setApiPrivateKey($privateKey);
    TrustedSearch::setApiEnvironment('sandbox');  //Options are sandbox or production
    TrustedSearch::setApiVersion('1'); //You MUST set this. 1 is currently the only option. There is no default.
```

#### Creating a Token.

[](#creating-a-token)

Tokens are used for whitelabel products.

```
$resource = TrustedSearch_Token::get($username, $password);
$data = $resource->getData();
echo $data['token'];
echo $data['expires'];
echo json_encode($data['userSettings']);
```

Version 1 API's
===============

[](#version-1-apis)

#### Get All Business for all users locations

[](#get-all-business-for-all-users-locations)

See the [API documentation](http://developers.trustedsearch.org/#/get-business-updates) for a list of parameters for each API resource.

```
$resource = TrustedSearch_DirectoryListing::get();
$data = $resource->getData();
echo json_encode($data);
```

#### Get Business Updates for single location

[](#get-business-updates-for-single-location)

See the [API documentation](http://developers.trustedsearch.org/#/get-business-updates) for a list of parameters for each API resource.

```
$testLocation = '45c907bc-6d2f-5f62-9610-5395858d41a0';
$resource = TrustedSearch_DirectoryListing::get($testLocation);
$data = $resource->getData();
echo json_encode($data);
```

#### Get Business Updates since epoch 1380611103

[](#get-business-updates-since-epoch-1380611103)

See the [API documentation](http://developers.trustedsearch.org/#/get-business-updates) for a list of parameters for each API resource.

```
$resource = TrustedSearch_DirectoryListing::since(1380611103);
$data = $resource->getData();
echo json_encode($data);
```

#### Submit New Business Listings

[](#submit-new-business-listings)

See the [API documentation](http://developers.trustedsearch.org/#/submitting-a-business) for a list of parameters for each API resource.

```
$data = array(
	array(
		'audit'=> false,
		'externalId' => 'mary_t123456240',
		'order' => array(
			"onBehalfOf" => "Partner ABC",
			'packages' => array(
				'ut002500'
			),
			'termsAccepted' => true
		),
		'contact' => array(
			'firstName' => 'Mary',
			'lastName' => 'Poppins',
			'email' => 'mary@poppins.com',
			'phone' => '8055551234'
		),
		'business' => array(
			'name' => "Jeremy's Umbrellas Shop",
			'street' => "17 Cherry Tree Lane",
			'city' => "London",
			'state' => "CA",
			'postalCode' => "93001",
			'phoneLocal' => "(805) 555-9876",
			'phoneTollFree'     => '(800) 555-5555',
			'fax'               => '(801) 555-5555',
			'website'           => 'http://www.marysumbrellas.com',
			'email'             => 'info@marysumbrellas.com',
			'slogan'            => "A spoon full of sugar helps the medicine go down.",
			'descriptionLong'   => 'some long desc...',
			'descriptionMedium' => 'some medium desc...',
			'descriptionShort'  => 'some short desc...',
			'keywords'          => 'rain gear, fashion, outdoor gear',
			'paymentMethods'    => array( 'mastercard', 'visa'),
			'category1'			=> 'outdoor',
			'category2'			=> 'fashion',
			'category3'			=> 'rain gear',
			'yearEstablished'   => '1808',
			'productsOffered'   => 'umbrellas, rain coats',
			'languagesSpoken'   => 'english, japanese, spanish',
			'hoursOfOperation'  => 'MF08001700H',
			'numberEmployees' 	=> 23,
			'logoUrl'           => "http://trustedsearch.org/images/imgTS_Logo.png",
			'logoSquareUrl'     => 'http://trustedsearch.org/images/imgTS_Logo.png',
			'imageUrl'=> array(
					'http://trustedsearch.org/images/imgTS_Logo.png',
					'http://trustedsearch.org/images/imgTS_Logo.png',
					'http://trustedsearch.org/images/imgTS_Logo.png',
					'http://trustedsearch.org/images/imgTS_Logo.png',
					'http://trustedsearch.org/images/imgTS_Logo.png',
				),
			'videoUrl' => 'http://www.youtube.com/watch?v=cXuTiAHdxTg'
		)
	),
	array(
		'audit'=> false,
		'externalId' => 'mary_t123456239',
		'order' => array(
			"onBehalfOf" => "Partner ABC",
			'packages' => array(
				'ut002500'
			),
			'termsAccepted' => true
		),
		'contact' => array(
			'firstName' => 'Mary',
			'lastName' => 'Poppins',
			'email' => 'mary@poppins.com',
			'phone' => '8055551234'
		),
		'business' => array(
			'name' => "Jeremy's Umbrellas Shop",
			'street' => "17 Cherry Tree Lane",
			'city' => "London",
			'state' => "CA",
			'postalCode' => "93001",
			'phoneLocal' => "(805) 555-9876",
			'phoneTollFree'     => '(800) 555-5555',
			'fax'               => '(801) 555-5555',
			'website'           => 'http://www.marysumbrellas.com',
			'email'             => 'info@marysumbrellas.com',
			'slogan'            => "A spoon full of sugar helps the medicine go down.",
			'descriptionLong'   => 'some long desc...',
			'descriptionMedium' => 'some medium desc...',
			'descriptionShort'  => 'some short desc...',
			'keywords'          => 'rain gear, fashion, outdoor gear',
			'paymentMethods'    => array( 'mastercard', 'visa'),
			'category1'			=> 'outdoor',
			'category2'			=> 'fashion',
			'category3'			=> 'rain gear',
			'yearEstablished'   => '1808',
			'productsOffered'   => 'umbrellas, rain coats',
			'languagesSpoken'   => 'english, japanese, spanish',
			'hoursOfOperation'  => 'MF08001700H',
			'numberEmployees' 	=> 23,
			'logoUrl'           => "http://trustedsearch.org/images/imgTS_Logo.png",
			'logoSquareUrl'     => 'http://trustedsearch.org/images/imgTS_Logo.png',
			'imageUrl'=> array(
					'http://trustedsearch.org/images/imgTS_Logo.png',
					'http://trustedsearch.org/images/imgTS_Logo.png',
					'http://trustedsearch.org/images/imgTS_Logo.png',
					'http://trustedsearch.org/images/imgTS_Logo.png',
					'http://trustedsearch.org/images/imgTS_Logo.png',
				),
			'videoUrl' => 'http://www.youtube.com/watch?v=cXuTiAHdxTg'
		)
	)
);  // end data array

$resource = TrustedSearch_LocalBusiness::create($data);
$data = $resource->getData();
echo json_encode($data);
```

#### Validating Business Listings

[](#validating-business-listings)

See the [API documentation](http://http://developers.trustedsearch.org/#/v1-validate) for a list of parameters for each API resource.

```
    $data = //Use same data structure as above to "Submit New Business Listings"

    try{
        $resource = TrustedSearch_LocalBusiness::validate($data);
            $data = $resource->getData();
            echo json_encode($data);
    }catch(TrustedSearch_Error $e){
        $errors = $e->getValidations();
        echo $errors['business.descriptionShort'];

    }
```

### Testing

[](#testing)

#### Testing / Simulating a change in a business listing

[](#testing--simulating-a-change-in-a-business-listing)

```
$uuid = '45c907bc-6d2f-5f62-9610-5395858d41a0'; //Take from response above.
$response = TrustedSearch_DirectoryListing::simulate($uuid);
echo json_encode($response->getData());
```

Version 2 API's
===============

[](#version-2-apis)

Don't forget to switch versions before a series of these calls:

```
TrustedSearch::setApiVersion('2');

```

### What's New!

[](#whats-new)

- Detailed error messages that include validation errors.
- Pagination
- CRUD on Resources.
- Standardized responses

Listings
--------

[](#listings)

#### TrustedSearch\_Listing::index

[](#trustedsearch_listingindex)

Page through and filter down any listing associated w/ your account.

See the [API documentation](http://developers.trustedsearch.org/#/listings) for a list of parameters for each API resource.

```
$page = 1;
$filters = array(
	fulfillment_status_id = "33"
);
$perPage = 25;
$sort = 'asc';
$orderBy = 'created_at';

$resource = TrustedSearch_Listing::index($page, $filters, $perPage, $sort, $orderBy);
$data = $resource->getData();
echo json_encode($data);
```

### Error Handling

[](#error-handling)

Exceptions are thrown when there is an api issue.

```
    try {
      $token = TrustedSearch_Token::get($username, $password);
    } catch (TrustedSearch_AuthenticationError $e) {
    	echo $e->getMessage();
	    $this->assertEquals(401, $e->getCode());
    }
```

#### Exceptions

[](#exceptions)

- TrustedSearch\_Error
    - Refer to [/lib/TrustedSearch/Errors/Error.php](/lib/TrustedSearch/Errors/Error.php) for special exception handle methods
- TrustedSearch\_ApiConnectionError
- TrustedSearch\_ApiError
- TrustedSearch\_AuthenticationError
- TrustedSearch\_InvalidRequestError

Output: (Body is formatted for readability.)

```
Message: Bummer, we couldn't save this record. You might have to fix a few things first and try again.

Body:

{
	"status"=>"error",
	"code"=>409,
	"message"=>"Bummer, we couldn't save this record. You might have to fix a few things first and try again.",
	"error"=>"ModelSaveFailedException",
	"debug"=>"Model was unable to save, check validation errors.",
	"validations"=>{"uuid"=>["The uuid field is required."],
	"business_name"=>["The business name field is required."]},
	"data"=>[]
}
Code: 409
```

Tests
-----

[](#tests)

In order to run tests you have to install PHPUnit () via Composer () (recommended way):

```
composer.phar update --dev

```

Run test suite:

```
php ./test/TrustedSearch.php

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~65 days

Recently: every ~76 days

Total

6

Last Release

4217d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/da4a8c6dbe7732db9e963084fbb75224797cd349ab3b490a0314a06c5fb782bc?d=identicon)[trustedsearch](/maintainers/trustedsearch)

---

Top Contributors

[![markalanevans](https://avatars.githubusercontent.com/u/129052?v=4)](https://github.com/markalanevans "markalanevans (57 commits)")

---

Tags

apitrustedsearchlocal business listings

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/trustedsearch-php-trustedsearch/health.svg)

```
[![Health](https://phpackages.com/badges/trustedsearch-php-trustedsearch/health.svg)](https://phpackages.com/packages/trustedsearch-php-trustedsearch)
```

###  Alternatives

[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
