varspool / jobadder-api-client
JobAdder API Client
Installs: 20 396
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 5
Open Issues: 4
Requires
- php: >=7.1.0
- jane/openapi-runtime: ^1.0
- psr/http-message: ^1.0
- psr/log: ^1.0
- roave/security-advisories: dev-master
- symfony/serializer: ^2.8|^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: 2.0.0-alpha
- jane/open-api: ^1.3
- phpunit/php-invoker: ^1.1
- phpunit/phpunit: ^6.1
README
A PHP API client for JobAdder, produced via jane-openapi
Installation
composer require varspool/jobadder-api-client
Usage
The namespace is Varspool\JobAdder
. The main client is Varspool\JobAdder\Client
. The Client class provides access to
a set of API resources:
$contacts = $client->contacts()->findContacts(['limit' => 3]); $ads = $client->jobAds()->getJobAds();
You can also access the resources directly from the Varspool\JobAdder\V2\Resource
namespace.
Instantiating a Client
The Client (and any Resource objects you create yourself) need to be given a configured HTTP client to be able to
communicate with JobAdder. This HTTP client should implement the HttpClient
or the HttpAsyncClient
from
HTTPlug. There are HTTPPlug adapters for most popular
HTTP clients in PHP (e.g. Guzzle)
Here's how you might use a Guzzle 6 client with this library:
-
Install the Guzzle adapter:
composer require php-http/guzzle6-adapter
-
Pass the Guzzle client into the JobAdder client via an adapter:
use GuzzleHttp\Client as GuzzleClient; use Varspool\JobAdder\Client as JobAdderClient; use Http\Adapter\Guzzle6\Client as GuzzleAdapter; $guzzle = new GuzzleClient($options); $http = new GuzzleAdapter($guzzle); $jobadder = new JobAdderClient($http);
OAuth and the Authorization header
Because the client is injected, you can configure things like the base URI (you should probably use the api
part of the
OAuth response from JobAdder), and the Authorization header:
// Get these both from the OAuth token response $api = 'https://localapi.jobadder.com/v2'; $token = 'abcdef01234567890'; $guzzle = new GuzzleClient([ 'base_uri' => $api, 'headers' => [ 'Authorization' => 'Bearer ' . $token ] ]);
Note that this client doesn't deal with the OAuth flow; it can take over once you have a valid access token.