antistatique / realforce-php-sdk
Super-simple, minimum abstraction Realforce API v1.x wrapper, in PHP
Installs: 670
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/antistatique/realforce-php-sdk
Requires
- php: >=8.3
- ext-curl: *
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.88
- php-coveralls/php-coveralls: ^2.8
- php-mock/php-mock-phpunit: ^2.13
- phpmd/phpmd: ^2.15
- phpunit/php-code-coverage: ^12.4
- phpunit/phpunit: ^12.3
- symfony/dotenv: ^7.3
- vimeo/psalm: ^6.13
This package is auto-updated.
Last update: 2025-09-30 14:21:02 UTC
README
Super-simple, minimum abstraction Realforce API v1.x wrapper, in PHP.
I hate complex wrappers. This lets you get from the Realforce API docs to the code as directly as possible.
Getting started
You can install realforce-php-sdk using Composer:
composer require antistatique/realforce-php-sdk
Examples
See the examples/ directory for examples of the key client features. You can view them in your browser by running the php built-in web server.
php -S localhost:8000 -t examples/
And then browsing to the host and port you specified (in the above example, http://localhost:8000).
Basic Example
Start by use-ing the class and creating an instance with your API key
use \Antistatique\Realforce\RealforceClient;
Every request should contain a valid API token. Use the RealforceClient::setApiToken method prior any requests.
All private operational requests require an authentication token.
Listing of Properties
Fetch a list of published properties' public data.
👉 https://github.com/realforce/documentation/blob/master/api-public/endpoints/properties-list.md
# Setup the Realforce client. $realforce = new RealforceClient(); $realforce->setApiToken($token); # Prepare the request. $query = new Antistatique\Realforce\Request\PropertiesListRequest(); $query ->lang(['fr', 'en']) ->page(0) ->perPage(10) ; # Fetch the list of properties. $response = $rf->publicProperties()->list($query); print_r($response);
Labels - Amenities
Fetch "amenities" labels linked to the public data you retrieve from the public API endpoints.
👉 https://github.com/realforce/documentation/blob/master/api-public/endpoints/labels-amenities.md
# Setup the Realforce client. $realforce = new RealforceClient(); $realforce->setApiToken($token); # Prepare the request. $query = new Antistatique\Realforce\Request\I18nRequest(); $query ->lang(['fr', 'en']) ; # Fetch the list of amenities' labels. $response = $rf->publicLabels()->amenities($query); print_r($response);
Labels - Categories
Fetch "categories" labels linked to the public data you retrieve from the public API endpoints.
👉 https://github.com/realforce/documentation/blob/master/api-public/endpoints/labels-categories.md
# Setup the Realforce client. $realforce = new RealforceClient(); $realforce->setApiToken($token); # Prepare the request. $query = new Antistatique\Realforce\Request\I18nRequest(); $query ->lang(['fr', 'en']) ; # Fetch the list od categories' labels. $response = $rf->publicLabels()->categories($query); print_r($response);
Labels - Categories
Fetch "locations" labels linked to the public data you retrieve from the public API endpoints.
👉 https://github.com/realforce/documentation/blob/master/api-public/endpoints/labels-locations.md
# Setup the Realforce client. $realforce = new RealforceClient(); $realforce->setApiToken($token); # Prepare the request. $query = new Antistatique\Realforce\Request\LocationsRequest(); $query ->isQuarter(true) ->lang(['fr', 'en']) ; # Fetch the list of locations' labels. $response = $rf->publicLabels()->locations($query); print_r($response);
Troubleshooting
To get the last error returned by either the HTTP client or by the API, use getLastError():
echo $rf->getLastError();
For further debugging, you can inspect the headers and body of the response:
print_r($rf->getLastResponse()); print_r($rf->getLastResponsetHttpStatus());
If you suspect you're sending data in the wrong format, you can look at what was sent to Realforce by the wrapper:
print_r($rf->getLastRequest());
If your server's CA root certificates are not up to date you may find that SSL verification fails and you don't get a response. The correction solution for this is not to disable SSL verification. The solution is to update your certificates. If you can't do that, there's an option at the top of the class file. Please don't just switch it off without at least attempting to update your certs -- that's lazy and dangerous. You're not a lazy, dangerous developer are you?