2017 © Pedro Peláez
 

library yelp-php

A php client for consuming Yelp API

image

moazam1/yelp-php

A php client for consuming Yelp API

  • Sunday, May 20, 2018
  • by moazam
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 21 Forks
  • 0 Open issues
  • 18 Versions
  • 0 % Grown

The README.md

Yelp PHP Client

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads, (*1)

A PHP client for authenticating with Yelp using OAuth and consuming the API., (*2)

Install

Via Composer, (*3)

``` bash $ composer require moazam1/yelp-php, (*4)


## Usage This package currently supports `v2` and `v3` (Fusion) of the Yelp API. Each version of the Yelp API maps to a different client, as the APIs are very different. Each client has separate documentation; links provided below. ### Create client Each version of the Yelp API maps to a different client, as the APIs are very different. A client factory is available to create appropriate clients. #### v2 Client Example ```php $options = array( 'consumerKey' => 'YOUR COSUMER KEY', 'consumerSecret' => 'YOUR CONSUMER SECRET', 'token' => 'YOUR TOKEN', 'tokenSecret' => 'YOUR TOKEN SECRET', 'apiHost' => 'api.yelp.com' // Optional, default 'api.yelp.com' ); $client = \Stevenmaguire\Yelp\ClientFactory::makeWith( $options, \Stevenmaguire\Yelp\Version::TWO );

v3 Client Example

$options = array(
    'accessToken' => 'YOUR ACCESS TOKEN', // Required, unless apiKey is provided
    'apiHost' => 'api.yelp.com', // Optional, default 'api.yelp.com',
    'apiKey' => 'YOUR ACCESS TOKEN', // Required, unless accessToken is provided
);

$client = \Stevenmaguire\Yelp\ClientFactory::makeWith(
    $options,
    \Stevenmaguire\Yelp\Version::THREE
);

Prior to December 7, 2017 accessToken was required to authenticate requests. Since then, apiKey is the preferred authentication method. This library supports both accessToken and apiKey, prioritizing apiKey over accessToken if both are provided., (*5)

https://www.yelp.com/developers/documentation/v3/authentication#where-is-my-client-secret-going, (*6)

Version Constant Documentation
v2 Stevenmaguire\Yelp\Version::TWO API-GUIDE-v2.md
v3 Stevenmaguire\Yelp\Version::THREE API-GUIDE-v3.md

Exceptions

If the API request results in an Http error, the client will throw a Stevenmaguire\Yelp\Exception\HttpException that includes the response body, as a string, from the Yelp API., (*7)

$responseBody = $e->getResponseBody(); // string from Http request
$responseBodyObject = json_decode($responseBody);

Advanced usage

Both the v3 client and the v2 client expose some public methods that allow overiding default behavior by providing alternative HTTP clients and requests., (*8)

$client = new \Stevenmaguire\Yelp\v3\Client(array(
    'accessToken' => $accessToken,
));

// Create a new guzzle http client
$specialHttpClient = new \GuzzleHttp\Client([
    // ... some special configuration
]);

// Update the yelp client with the new guzzle http client
// then get business data
$business = $client->setHttpClient($specialHttpClient)
    ->getBusiness('the-motel-bar-chicago');

// Create request for other yelp API resource not supported by yelp-php
$request = $client->getRequest('GET', '/v3/some-future-endpoint');

// Send that request
$response = $client->getResponse($request);

// See the contents
echo $response->getBody();

Upgrading with Yelp API v2 support from yelp-php 1.x to yelp-php 2.x

// same options for all
$options = array(
    'consumerKey' => 'YOUR COSUMER KEY',
    'consumerSecret' => 'YOUR CONSUMER SECRET',
    'token' => 'YOUR TOKEN',
    'tokenSecret' => 'YOUR TOKEN SECRET',
    'apiHost' => 'api.yelp.com' // Optional, default 'api.yelp.com'
);


// yelp-php 1.x
$client = new Stevenmaguire\Yelp\Client($options);

// yelp-php 2.x - option 1
$client = \Stevenmaguire\Yelp\ClientFactory::makeWith(
    $options,
    \Stevenmaguire\Yelp\Version::TWO
);

// yelp-php 2.x - option 2
$client = new \Stevenmaguire\Yelp\v2\Client($options);

Testing

bash $ ./vendor/bin/phpunit, (*9)

Contributing

Please see CONTRIBUTING for details., (*10)

Credits

License

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

The Versions

20/05 2018

dev-master

9999999-dev http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

api php oauth2 oauth1 yelp

11/03 2018

dev-added-missing-comma-in-the-v3-example-code

dev-added-missing-comma-in-the-v3-example-code http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php oauth2 oauth1 yelp

10/02 2018

2.1.0

2.1.0.0 http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php oauth2 oauth1 yelp

26/06 2017

2.0.0

2.0.0.0 http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php oauth2 oauth1 yelp

28/03 2016

1.4.3

1.4.3.0 http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php oauth1 yelp

23/11 2015

1.4.2

1.4.2.0 http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php oauth1 yelp

17/11 2015

1.4.1

1.4.1.0 http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php oauth1 yelp

27/08 2015

1.4.0

1.4.0.0 http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php oauth1 yelp

14/08 2015

1.2.1

1.2.1.0 http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php oauth1 yelp

14/08 2015

1.3.0

1.3.0.0 http://github.com/stevenmaguire/yelp-php

A php client for consuming Yelp API

  Sources   Download

MIT

The Requires

 

The Development Requires

api php oauth1 yelp

22/05 2015

1.2.0

1.2.0.0 http://github.com/stevenmaguire/yelp-php

A php client for consumer Yelp API

  Sources   Download

MIT

The Requires

 

api php oauth1 yelp

23/04 2015

1.1.0

1.1.0.0 http://github.com/stevenmaguire/yelp-php

A php client for consumer Yelp API

  Sources   Download

MIT

The Requires

 

api php oauth1 yelp

23/04 2015

1.0.7

1.0.7.0 http://github.com/stevenmaguire/yelp-php

A php client for consumer Yelp API

  Sources   Download

MIT

The Requires

 

api php oauth1 yelp

31/03 2015

1.0.6

1.0.6.0 http://github.com/stevenmaguire/yelp-php

A php client for consumer Yelp API

  Sources   Download

MIT

The Requires

 

api php oauth1 yelp

30/01 2015

1.0.4

1.0.4.0 http://github.com/stevenmaguire/yelp-php

A php client for consumer Yelp API

  Sources   Download

MIT

The Requires

 

11/01 2015

1.0.2

1.0.2.0 http://github.com/stevenmaguire/yelp-php

A php client for consumer Yelp API

  Sources   Download

MIT

The Requires

 

11/01 2015

1.0.0

1.0.0.0 http://github.com/stevenmaguire/yelp-php

A php client for consumer Yelp API

  Sources   Download

MIT

The Requires

 

21/10 2014

0.0.1

0.0.1.0

A php client for consumer Yelp API

  Sources   Download

MIT

The Requires